Skip to content

Commit

Permalink
feat: add support for oelint-adv (#598)
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen authored Jan 12, 2025
1 parent 792333f commit 7da8146
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [Unreleased](https://github.com/hougesen/mdsf/compare/v0.3.2...HEAD)

- feat: add support for oelint-adv [`#598`](https://github.com/hougesen/mdsf/pull/598)
- feat: add support for mypy [`#597`](https://github.com/hougesen/mdsf/pull/597)
- feat: add support for luacheck [`#596`](https://github.com/hougesen/mdsf/pull/596)
- feat: add support for htmlhint [`#595`](https://github.com/hougesen/mdsf/pull/595)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ mdsf init
<!-- START_SECTION:supported-tools -->

`mdsf` currently supports 229 tools. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃
`mdsf` currently supports 230 tools. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃

| Name | Description | Categories | Languages |
| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------------------------------------------------- |
Expand Down Expand Up @@ -355,6 +355,7 @@ mdsf init
| [ocamlformat](https://github.com/ocaml-ppx/ocamlformat) | Auto-formatter for OCaml code | `formatter` | `ocaml` |
| [ocp-indent](https://github.com/OCamlPro/ocp-indent) | Indentation tool for OCaml | `formatter` | `ocaml` |
| [odinfmt](https://github.com/DanielGavin/ols) | Formatter for the Odin programming language | `formatter` | `odin` |
| [oelint-adv](https://github.com/priv-kweihmann/oelint-adv) | Advanced oelint | `linter` | `bitbake` |
| [opa](https://www.openpolicyagent.org/docs/latest/cli/) | Format Rego source files | `formatter` | `rego` |
| [ormolu](https://github.com/tweag/ormolu) | A formatter for Haskell source code | `formatter` | `haskell` |
| [oxlint](https://oxc.rs/docs/guide/usage/linter.html) | Oxlint is designed to catch erroneous or useless code without requiring any configurations by default | `linter` | `javascript`, `typescript` |
Expand Down
7 changes: 7 additions & 0 deletions mdsf/src/tools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ pub mod nufmt;
pub mod ocamlformat;
pub mod ocp_indent;
pub mod odinfmt;
pub mod oelint_adv;
pub mod opa_fmt;
pub mod ormolu;
pub mod oxlint;
Expand Down Expand Up @@ -814,6 +815,10 @@ pub enum Tooling {
/// `odinfmt -w $PATH`
Odinfmt,

#[serde(rename = "oelint-adv")]
/// `oelint-adv --fix --nobackup --quiet $PATH`
OelintAdv,

#[serde(rename = "opa:fmt")]
/// `opa fmt $PATH -w`
OpaFmt,
Expand Down Expand Up @@ -1350,6 +1355,7 @@ impl Tooling {
Self::Ocamlformat => ocamlformat::run(snippet_path),
Self::OcpIndent => ocp_indent::run(snippet_path),
Self::Odinfmt => odinfmt::run(snippet_path),
Self::OelintAdv => oelint_adv::run(snippet_path),
Self::OpaFmt => opa_fmt::run(snippet_path),
Self::Ormolu => ormolu::run(snippet_path),
Self::Oxlint => oxlint::run(snippet_path),
Expand Down Expand Up @@ -1598,6 +1604,7 @@ impl AsRef<str> for Tooling {
Self::Ocamlformat => "ocamlformat",
Self::OcpIndent => "ocp_indent",
Self::Odinfmt => "odinfmt",
Self::OelintAdv => "oelint_adv",
Self::OpaFmt => "opa_fmt",
Self::Ormolu => "ormolu",
Self::Oxlint => "oxlint",
Expand Down
37 changes: 37 additions & 0 deletions mdsf/src/tools/oelint_adv.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use std::process::Command;

use crate::{error::MdsfError, execution::execute_command, runners::CommandType};

#[inline]
fn set_oelint_adv_args(mut cmd: Command, file_path: &std::path::Path) -> Command {
cmd.arg("--fix");
cmd.arg("--nobackup");
cmd.arg("--quiet");
cmd.arg(file_path);
cmd
}

#[inline]
pub fn run(file_path: &std::path::Path) -> Result<(bool, Option<String>), MdsfError> {
let commands = [CommandType::Direct("oelint-adv")];

for (index, cmd) in commands.iter().enumerate() {
let cmd = set_oelint_adv_args(cmd.build(), file_path);
let execution_result = execute_command(cmd, file_path);

if index == commands.len() - 1 {
return execution_result;
}

if let Ok(r) = execution_result {
if !r.0 {
return Ok(r);
}
}
}

Ok((true, None))
}

#[cfg(test)]
mod test_oelint_adv {}
5 changes: 5 additions & 0 deletions schemas/v0.3.3-dev/mdsf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,11 @@
"type": "string",
"enum": ["odinfmt"]
},
{
"description": "`oelint-adv --fix --nobackup --quiet $PATH`",
"type": "string",
"enum": ["oelint-adv"]
},
{
"description": "`opa fmt $PATH -w`",
"type": "string",
Expand Down
15 changes: 15 additions & 0 deletions tools/oelint-adv/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "../tool.schema.json",
"binary": "oelint-adv",
"categories": ["linter"],
"commands": {
"": ["--fix", "--nobackup", "--quiet", "$PATH"]
},
"description": "Advanced oelint",
"homepage": "https://github.com/priv-kweihmann/oelint-adv",
"languages": ["bitbake"],
"name": null,
"npm": null,
"php": null,
"tests": []
}

0 comments on commit 7da8146

Please sign in to comment.