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.89k stars 228 forks source link

Cannot get SPELL_CSPELL to work #1976

Closed kcfedun-fincad closed 1 year ago

kcfedun-fincad commented 1 year ago

The cspell linter works fine from the CLI, but when using it via MegaLinter, it doesn't work (notice that it doesn't even show up in the matching linters table).

$ cspell -c .cspell.json v2022.03.24.rst 
1/1 ./v2022.03.24.rst 372.27ms X
./v2022.03.24.rst:60:41 - Unknown word (AUDJPY)
./v2022.03.24.rst:63:44 - Unknown word (BBSW)
./v2022.03.24.rst:256:116 - Unknown word (hashable)
./v2022.03.24.rst:262:12 - Unknown word (USDCAD)
./v2022.03.24.rst:262:33 - Unknown word (CDOR)
./v2022.03.24.rst:318:30 - Unknown word (ISMA)
./v2022.03.24.rst:318:42 - Unknown word (ISMA)
./v2022.03.24.rst:318:93 - Unknown word (ISMA)
./v2022.03.24.rst:318:107 - Unknown word (ISMA)
CSpell: Files checked: 1, Issues found: 9 in 1 files
$ mega-linter-runner --flavor python
Pulling docker image oxsecurity/megalinter-python:v6 ... 
INFO: this operation can be long during the first use of mega-linter-runner
The next runs, it will be immediate (thanks to docker cache !)
v6: Pulling from oxsecurity/megalinter-python
Digest: sha256:2d209ffc1457a60583d26d3692dd475a1237ba028fc8d0da4f5b43382cae5a05
Status: Image is up to date for oxsecurity/megalinter-python:v6
docker.io/oxsecurity/megalinter-python:v6
Command: docker run -v /var/run/docker.sock:/var/run/docker.sock:rw -v <redacted>:/tmp/lint:rw oxsecurity/megalinter-python:v6
Skipped setting git safe.directory DEFAULT_WORKSPACE:  ...
Setting git safe.directory default: /github/workspace ...
Setting git safe.directory to /tmp/lint ...
[MegaLinter init] ONE-SHOT RUN
[config] /tmp/lint/.mega-linter.yml + Environment variables
----------------------------------------------------------------------------------------------------
------------------------------------ MegaLinter, by OX Security ------------------------------------
----------------------------------------------------------------------------------------------------
 - Image Creation Date: 2022-10-16T19:54:59Z
 - Image Revision: f14608f
 - Image Version: v6
----------------------------------------------------------------------------------------------------
The MegaLinter documentation can be found at:
 - https://oxsecurity.github.io/megalinter/latest
----------------------------------------------------------------------------------------------------
MegaLinter initialization

MARKDOWN_REMARK_LINT has been temporary disabled in MegaLinter, please use a previous MegaLinter version or wait for the next one !
Skipped linters: ACTION_ACTIONLINT, ANSIBLE_ANSIBLE_LINT, ARM_ARM_TTK, BASH_EXEC, BASH_SHELLCHECK, BASH_SHFMT, BICEP_BICEP_LINTER, CLOJURE_CLJ_KONDO, CLOUDFORMATION_CFN_LINT, COFFEE_COFFEELINT, COPYPASTE_JSCPD, CPP_CPPLINT, CSHARP_DOTNET_FORMAT, CSS_SCSS_LINT, CSS_STYLELINT, C_CPPLINT, DART_DARTANALYZER, DOCKERFILE_HADOLINT, EDITORCONFIG_EDITORCONFIG_CHECKER, ENV_DOTENV_LINTER, GHERKIN_GHERKIN_LINT, GO_GOLANGCI_LINT, GO_REVIVE, GRAPHQL_GRAPHQL_SCHEMA_LINTER, GROOVY_NPM_GROOVY_LINT, HTML_DJLINT, HTML_HTMLHINT, JAVASCRIPT_ES, JAVASCRIPT_PRETTIER, JAVASCRIPT_STANDARD, JAVA_CHECKSTYLE, JAVA_PMD, JSON_ESLINT_PLUGIN_JSONC, JSON_JSONLINT, JSON_PRETTIER, JSON_V8R, JSX_ESLINT, KOTLIN_KTLINT, KUBERNETES_KUBECONFORM, KUBERNETES_KUBEVAL, LATEX_CHKTEX, LUA_LUACHECK, MAKEFILE_CHECKMAKE, MARKDOWN_MARKDOWNLINT, MARKDOWN_MARKDOWN_LINK_CHECK, MARKDOWN_MARKDOWN_TABLE_FORMATTER, MARKDOWN_REMARK_LINT, OPENAPI_SPECTRAL, PERL_PERLCRITIC, PHP_PHPCS, PHP_PHPLINT, PHP_PHPSTAN, PHP_PSALM, POWERSHELL_POWERSHELL, PROTOBUF_PROTOLINT, PUPPET_PUPPET_LINT, PYTHON_BANDIT, PYTHON_BLACK, PYTHON_FLAKE8, PYTHON_ISORT, PYTHON_MYPY, PYTHON_PYLINT, PYTHON_PYRIGHT, RAKU_RAKU, REPOSITORY_CHECKOV, REPOSITORY_DEVSKIM, REPOSITORY_DUSTILOCK, REPOSITORY_GITLEAKS, REPOSITORY_GIT_DIFF, REPOSITORY_GOODCHECK, REPOSITORY_SECRETLINT, REPOSITORY_SEMGREP, REPOSITORY_SYFT, REPOSITORY_TRIVY, RST_RSTCHECK, RST_RST_LINT, RUBY_RUBOCOP, RUST_CLIPPY, R_LINTR, SALESFORCE_SFDX_SCANNER_APEX, SALESFORCE_SFDX_SCANNER_AURA, SALESFORCE_SFDX_SCANNER_LWC, SCALA_SCALAFIX, SNAKEMAKE_LINT, SNAKEMAKE_SNAKEFMT, SPELL_MISSPELL, SPELL_PROSELINT, SQL_SQLFLUFF, SQL_SQL_LINT, SQL_TSQLLINT, SWIFT_SWIFTLINT, TEKTON_TEKTON_LINT, TERRAFORM_CHECKOV, TERRAFORM_KICS, TERRAFORM_TERRAFORM_FMT, TERRAFORM_TERRAGRUNT, TERRAFORM_TERRASCAN, TERRAFORM_TFLINT, TSX_ESLINT, TYPESCRIPT_ES, TYPESCRIPT_PRETTIER, TYPESCRIPT_STANDARD, VBDOTNET_DOTNET_FORMAT, XML_XMLLINT, YAML_PRETTIER, YAML_V8R, YAML_YAMLLINT
To receive reports as email, please set variable EMAIL_REPORTER_EMAIL

MegaLinter now collects the files to analyse
Listing all files in directory [/tmp/lint], then filter with:
- Excluding .gitignored files [65179]: /tmp/lint/.coverage, /tmp/lint/.doit.db, /tmp/lint/.editorconfig, /tmp/lint/.env, /tmp/lint/.pytest_cache/.gitignore, /tmp/lint/.pytest_cache/CACHEDIR.TAG, /tmp/lint/.pytest_cache/README.md, /tmp/lint/.pytest_cache/v/cache/stepwise, /tmp/lint/.venv/LICENSE, /tmp/lint/.venv/bin/Activate.ps1,...(full list in DEBUG)
Kept [0] files on [6770] found files

+----MATCHING LINTERS-+----------+----------------+------------+
| Descriptor | Linter | Criteria | Matching files | Format/Fix |
+------------+--------+----------+----------------+------------+

+----SUMMARY-+--------+------+-------+-------+--------+--------------+
| Descriptor | Linter | Mode | Files | Fixed | Errors | Elapsed time |
+------------+--------+------+-------+-------+--------+--------------+

[Updated Sources Reporter] copied 14 fixed source files in folder /tmp/lint/megalinter-reports/updated_sources.
Download it from artifacts then copy-paste it in your local repo to apply linters updates
::set-output name=has_updated_sources::0
✅ Successfully linted all files without errors
.mega-linter.yml
------------------

APPLY_FIXES: none # all, none, or list of linter keys
ENABLE_LINTERS: # If you use ENABLE_LINTERS variable, all other linters will be disabled by default
  - SPELL_CSPELL
SHOW_ELAPSED_TIME: true
FILEIO_REPORTER: false
CLEAR_REPORT_FOLDER: true
PRINT_ALPACA: false
.cspell.json
------------

{
  "language": "en",
  "noConfigSearch": true,
  "words": ["megalinter", "oxsecurity"],
  "version": "0.2"
}
Kurt-von-Laven commented 1 year ago

CSpell runs fine for us in ScribeMD/slack-templates where we use the Python flavor at MegaLinter version v6.12.0. Do you experience the same bug at v6.12.0? If so, maybe try setting SPELL_CSPELL_CONFIG_FILE: LINTER_DEFAULT in your .mega-linter.yml or, more generally, configure your repository increasingly similarly to ours until the issue is revealed? I'm not an expert on CSpell, but I don't see mention of noConfigSearch in CSpell's documentation.

nvuillam commented 1 year ago

spelling linters have a particular behaviour: they analyze all files that are analyzed by other linters :)

nvuillam commented 1 year ago

So if CSPELL is the only active linter, it will indeed detect no file to analyze Maybe u'd like to add more linters ?

kcfedun-fincad commented 1 year ago

spelling linters have a particular behaviour: they analyze all files that are analyzed by other linters :)

Bingo, this was the issue. I do plan to use other linters, but I was testing them one-by-one at first and thus the confusion when this one stopped working. Many thanks!

nvuillam commented 1 year ago

You're welcome, good hunt :)