oxsecurity / megalinter

🦙 MegaLinter analyzes 50 languages, 22 formats, 21 tooling formats, excessive copy-pastes, spelling mistakes and security issues in your repository sources with a GitHub Action, other CI tools or locally.
https://megalinter.io
GNU Affero General Public License v3.0
1.81k stars 215 forks source link

JSON Schema out-of-date #615

Closed lars-reimann closed 2 years ago

lars-reimann commented 2 years ago

Describe the bug The JSON schema seems to be missing some options that are mentioned in the documentation.

I checked all linters and all common variables but none of the other parts of the schema.

To Reproduce Steps to reproduce the behavior:

  1. Compare configuration docs with JSON schema
  2. Compare linter list in docs with JSON schema

Expected behavior Docs and schema should match.

Screenshots If applicable, add screenshots to help explain your problem.

image

Additional context I just want to say thanks for a very promising and useful tool.

nvuillam commented 2 years ago

@lars-reimann > That's true for IGNORE_GENERATED_FILE that I forgot (PR in progress), but for the linters you identified, they are part of JSON schema (which is mostly generated automatically from linter descriptors)

image

What IDE do you use ? It seems the used JSON schema is out of date :/

lars-reimann commented 2 years ago

That's curious. The current state for me is:

lars-reimann commented 2 years ago

@nvuillam IntelliJ seems to be using this section of the schema, which is indeed missing these keys:

  "description": "Mega-Linter configuration file",
  "enum_linter_keys": {
    "enum": [
      "ANSIBLE_ANSIBLE_LINT",
      "ARM_ARM_TTK",
      "BASH_EXEC",
      "BASH_SHELLCHECK",
      "BASH_SHFMT",
      "C_CPPLINT",
      "CLOJURE_CLJ_KONDO",
      "CLOUDFORMATION_CFN_LINT",
      "COFFEE_COFFEELINT",
      "COPYPASTE_JSCPD",
      "CPP_CPPLINT",
      "CSHARP_DOTNET_FORMAT",
      "CSS_STYLELINT",
      "CSS_SCSS_LINT",
      "DART_DARTANALYZER",
      "DOCKERFILE_DOCKERFILELINT",
      "DOCKERFILE_HADOLINT",
      "EDITORCONFIG_EDITORCONFIG_CHECKER",
      "ENV_DOTENV_LINTER",
      "GHERKIN_GHERKIN_LINT",
      "GIT_GIT_DIFF",
      "GO_GOLANGCI_LINT",
      "GRAPHQL_GRAPHQL_SCHEMA_LINTER",
      "GROOVY_NPM_GROOVY_LINT",
      "HTML_HTMLHINT",
      "JAVA_CHECKSTYLE",
      "JAVASCRIPT_ES",
      "JAVASCRIPT_STANDARD",
      "JAVASCRIPT_PRETTIER",
      "JSON_JSONLINT",
      "JSON_ESLINT_PLUGIN_JSONC",
      "JSON_V8R",
      "JSX_ESLINT",
      "KOTLIN_KTLINT",
      "KUBERNETES_KUBEVAL",
      "LATEX_CHKTEX",
      "LUA_LUACHECK",
      "MARKDOWN_MARKDOWNLINT",
      "MARKDOWN_REMARK_LINT",
      "MARKDOWN_MARKDOWN_LINK_CHECK",
      "OPENAPI_SPECTRAL",
      "PERL_PERLCRITIC",
      "PHP_BUILTIN",
      "PHP_PHPCS",
      "PHP_PHPSTAN",
      "PHP_PSALM",
      "POWERSHELL_POWERSHELL",
      "PROTOBUF_PROTOLINT",
      "PUPPET_PUPPET_LINT",
      "PYTHON_PYLINT",
      "PYTHON_BLACK",
      "PYTHON_FLAKE8",
      "PYTHON_ISORT",
      "R_LINTR",
      "RAKU_RAKU",
      "RST_RST_LINT",
      "RST_RSTCHECK",
      "RST_RSTFMT",
      "RUBY_RUBOCOP",
      "RUST_CLIPPY",
      "SALESFORCE_SFDX_SCANNER",
      "SCALA_SCALAFIX",
      "SNAKEMAKE_LINT",
      "SNAKEMAKE_SNAKEFMT",
      "SPELL_MISSPELL",
      "SPELL_CSPELL",
      "SQL_SQL_LINT",
      "TEKTON_TEKTON_LINT",
      "TERRAFORM_TFLINT",
      "TERRAFORM_TERRASCAN",
      "TERRAFORM_TERRAGRUNT",
      "TSX_ESLINT",
      "TYPESCRIPT_ES",
      "TYPESCRIPT_STANDARD",
      "TYPESCRIPT_PRETTIER",
      "VBDOTNET_DOTNET_FORMAT",
      "XML_XMLLINT",
      "YAML_YAMLLINT",
      "YAML_V8R"
    ],
    "type": "string"
  },
nvuillam commented 2 years ago

Those keys are not missing in master version of the schema ^^

https://github.com/nvuillam/mega-linter/blob/b4761190ddb97fcac8070473b878a067bccc91e3/megalinter/descriptors/schemas/megalinter-configuration.jsonschema.json#L100

From where is your JSON sample ? it does not contain MARKDOWN_MARKDOWN_TABLE_FORMATTER whereas it is available in Mega-Linter repo ->

image

lars-reimann commented 2 years ago

@nvuillam Unless I have some really weird caching issues on my side, they are missing, though. It's a different location than you pointed to. See https://github.com/nvuillam/mega-linter/blob/b4761190ddb97fcac8070473b878a067bccc91e3/megalinter/descriptors/schemas/megalinter-configuration.jsonschema.json#L239

I think there might be some unintended duplication in the schema.

nvuillam commented 2 years ago

I just clicked on your hyperlink and saw markdown table formatter entry, do you see it on your link ? Screenshot_20210805-145021.png

lars-reimann commented 2 years ago

@nvuillam In line 144, yes. In line 239, where I pointed to, no. The entire part "enum_linter_keys" is defined twice, note the different line numbers:

https://github.com/nvuillam/mega-linter/blob/b4761190ddb97fcac8070473b878a067bccc91e3/megalinter/descriptors/schemas/megalinter-configuration.jsonschema.json#L100

https://github.com/nvuillam/mega-linter/blob/b4761190ddb97fcac8070473b878a067bccc91e3/megalinter/descriptors/schemas/megalinter-configuration.jsonschema.json#L198

If I remove the second occurrence (line 198), IntelliJ is happy. I'm unsure what the semantics of the second occurrence are anyway, since it's outside the definitions block. VS Code apparently ignores it, while IntelliJ overrides the original definition (line 100).

nvuillam commented 2 years ago

You're totally right, enum_linter_keys should be only within definitions :) Thanks for the PR !