diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fe0acfd..efd8e02b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/README.md b/README.md index b682347c..b5240fc9 100644 --- a/README.md +++ b/README.md @@ -214,7 +214,7 @@ mdsf init -`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 | | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------------------------------------------------- | @@ -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` | diff --git a/mdsf/src/tools/mod.rs b/mdsf/src/tools/mod.rs index bc677a05..9de80148 100644 --- a/mdsf/src/tools/mod.rs +++ b/mdsf/src/tools/mod.rs @@ -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; @@ -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, @@ -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), @@ -1598,6 +1604,7 @@ impl AsRef 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", diff --git a/mdsf/src/tools/oelint_adv.rs b/mdsf/src/tools/oelint_adv.rs new file mode 100644 index 00000000..bfa29366 --- /dev/null +++ b/mdsf/src/tools/oelint_adv.rs @@ -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), 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 {} diff --git a/schemas/v0.3.3-dev/mdsf.schema.json b/schemas/v0.3.3-dev/mdsf.schema.json index 3408860d..63827dbc 100644 --- a/schemas/v0.3.3-dev/mdsf.schema.json +++ b/schemas/v0.3.3-dev/mdsf.schema.json @@ -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", diff --git a/tools/oelint-adv/plugin.json b/tools/oelint-adv/plugin.json new file mode 100644 index 00000000..2633f086 --- /dev/null +++ b/tools/oelint-adv/plugin.json @@ -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": [] +}