Skip to content

Commit

Permalink
feat(cli): support codeql query format (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen authored Feb 8, 2025
1 parent f832126 commit 0de89fd
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 4 deletions.
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.5.0...HEAD)

- feat(cli): support codeql query format [`#677`](https://github.com/hougesen/mdsf/pull/677)
- chore: set dev version to v0.5.1-dev [`#676`](https://github.com/hougesen/mdsf/pull/676)
- refactor(cli): remove once_cell dependency [`#675`](https://github.com/hougesen/mdsf/pull/675)

Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ mdsf init
<!-- START_SECTION:supported-tools -->

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

| Name | Description | Categories | Languages |
| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------------------------------------------------- |
Expand Down Expand Up @@ -379,6 +379,7 @@ mdsf init
| [cljfmt](https://github.com/weavejester/cljfmt) | A tool for formatting Clojure code | `formatter` | `clojure` |
| [cljstyle](https://github.com/greglook/cljstyle) | A tool for formatting Clojure code | `formatter` | `clojure` |
| [cmake-format](https://cmake-format.readthedocs.io/en/latest/cmake-format.html) | cmake-format can format your listfiles nicely so that they don't look like crap | `formatter` | `cmake` |
| [codeql](https://docs.github.com/en/code-security/codeql-cli/codeql-cli-manual) | Format queries and libraries with CodeQL | `formatter` | `codeql` |
| [codespell](https://github.com/codespell-project/codespell) | Check code for common misspellings | `autocorrection` | |
| [coffeelint](https://github.com/coffeelint/coffeelint) | Lint your CoffeeScript | `linter` | `coffeescript` |
| [crlfmt](https://github.com/cockroachdb/crlfmt) | Formatter for CockroachDB's additions to the Go style guide | `formatter` | `go` |
Expand Down Expand Up @@ -445,7 +446,7 @@ mdsf init
| [isort](https://github.com/timothycrosley/isort) | A Python utility to sort imports | `formatter` | `python` |
| [joker](https://github.com/candid82/joker) | Small Clojure interpreter, linter and formatter | `formatter`, `linter` | `clojure` |
| [js-beautify](https://github.com/beautifier/js-beautify) | A JavaScript formatter | `formatter` | `javascript` |
| [json5format](https://github.com/google/json5format) | JSON5 (a.k.a., "JSON for Humans") formatter that preserves contextual comments | `formatter` | `json5`, `json` |
| [json5format](https://github.com/google/json5format) | JSON5 (a.k.a., JSON for Humans) formatter that preserves contextual comments | `formatter` | `json5`, `json` |
| [jsona](https://github.com/jsona/jsona) | JSONA linter and formatter | `formatter`, `linter` | `jsona` |
| [jsonlint](https://github.com/zaach/jsonlint) | A JSON parser and validator with a CLI | `formatter`, `linter` | `json` |
| [jsonnet-lint](https://jsonnet.org/learning/tools.html) | Linter for jsonnet files | `linter` | `jsonnet` |
Expand Down Expand Up @@ -595,7 +596,7 @@ mdsf init

<!-- START_SECTION:supported-commands -->

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

| Name | Command |
| ------------------------ | --------------------------------------------------------------------------------------- |
Expand Down Expand Up @@ -638,6 +639,7 @@ mdsf init
| `cljfmt:fix` | `cljfmt fix $PATH` |
| `cljstyle` | `cljstyle fix $PATH` |
| `cmake-format` | `cmake-format -i $PATH` |
| `codeql:query:format` | `codeql query format -i $PATH` |
| `codespell` | `codespell $PATH --check-hidden --write-changes` |
| `coffeelint` | `coffeelint -q -f $PATH` |
| `crlfmt` | `crlfmt -w $PATH` |
Expand Down
21 changes: 21 additions & 0 deletions mdsf/src/tools/codeql_query_format.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
///
/// THIS FILE IS GENERATED USING CODE - DO NOT EDIT MANUALLY
///
use crate::runners::CommandType;

#[inline]
pub fn set_args(
mut cmd: std::process::Command,
file_path: &std::path::Path,
) -> std::process::Command {
cmd.arg("query");
cmd.arg("format");
cmd.arg("-i");
cmd.arg(file_path);
cmd
}

pub const COMMANDS: [CommandType; 1] = [CommandType::Direct("codeql")];

#[cfg(test)]
mod test_codeql_query_format {}
10 changes: 10 additions & 0 deletions mdsf/src/tools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub mod clang_tidy;
pub mod cljfmt_fix;
pub mod cljstyle;
pub mod cmake_format;
pub mod codeql_query_format;
pub mod codespell;
pub mod coffeelint;
pub mod crlfmt;
Expand Down Expand Up @@ -420,6 +421,10 @@ pub enum Tooling {
/// `cmake-format -i $PATH`
CmakeFormat,

#[serde(rename = "codeql:query:format")]
/// `codeql query format -i $PATH`
CodeqlQueryFormat,

#[serde(rename = "codespell")]
/// `codespell $PATH --check-hidden --write-changes`
Codespell,
Expand Down Expand Up @@ -1348,6 +1353,10 @@ impl Tooling {
Self::CljfmtFix => (&cljfmt_fix::COMMANDS, cljfmt_fix::set_args),
Self::Cljstyle => (&cljstyle::COMMANDS, cljstyle::set_args),
Self::CmakeFormat => (&cmake_format::COMMANDS, cmake_format::set_args),
Self::CodeqlQueryFormat => (
&codeql_query_format::COMMANDS,
codeql_query_format::set_args,
),
Self::Codespell => (&codespell::COMMANDS, codespell::set_args),
Self::Coffeelint => (&coffeelint::COMMANDS, coffeelint::set_args),
Self::Crlfmt => (&crlfmt::COMMANDS, crlfmt::set_args),
Expand Down Expand Up @@ -1626,6 +1635,7 @@ impl AsRef<str> for Tooling {
Self::CljfmtFix => "cljfmt_fix",
Self::Cljstyle => "cljstyle",
Self::CmakeFormat => "cmake_format",
Self::CodeqlQueryFormat => "codeql_query_format",
Self::Codespell => "codespell",
Self::Coffeelint => "coffeelint",
Self::Crlfmt => "crlfmt",
Expand Down
5 changes: 5 additions & 0 deletions schemas/v0.5.1-dev/mdsf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@
"type": "string",
"enum": ["cmake-format"]
},
{
"description": "`codeql query format -i $PATH`",
"type": "string",
"enum": ["codeql:query:format"]
},
{
"description": "`codespell $PATH --check-hidden --write-changes`",
"type": "string",
Expand Down
16 changes: 16 additions & 0 deletions tools/codeql/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "../tool.schema.json",
"binary": "codeql",
"categories": ["formatter"],
"commands": {
"query:format": {
"arguments": ["query", "format", "-i", "$PATH"],
"description": "Format queries and libraries with CodeQL",
"homepage": "https://docs.github.com/en/code-security/codeql-cli/codeql-cli-manual/query-format"
}
},
"description": "Format queries and libraries with CodeQL",
"homepage": "https://docs.github.com/en/code-security/codeql-cli/codeql-cli-manual",
"languages": ["codeql"],
"packages": {}
}
2 changes: 1 addition & 1 deletion tools/json5format/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"arguments": ["-r", "$PATH"]
}
},
"description": "JSON5 (a.k.a., \"JSON for Humans\") formatter that preserves contextual comments",
"description": "JSON5 (a.k.a., JSON for Humans) formatter that preserves contextual comments",
"homepage": "https://github.com/google/json5format",
"languages": ["json", "json5"],
"packages": {}
Expand Down

0 comments on commit 0de89fd

Please sign in to comment.