megalinter icon indicating copy to clipboard operation
megalinter copied to clipboard

Use relative file paths to call linters

Open nvuillam opened this issue 3 years ago • 1 comments

Fixes https://github.com/oxsecurity/megalinter/issues/1875

nvuillam avatar Sep 15 '22 20:09 nvuillam

🦙 MegaLinter status: ⚠️ WARNING

Descriptor Linter Files Fixed Errors Elapsed time
✅ BASH bash-exec 6 0 0.02s
✅ BASH shellcheck 6 0 0.17s
✅ BASH shfmt 6 0 0 0.45s
✅ COPYPASTE jscpd yes no 3.93s
✅ DOCKERFILE hadolint 117 0 24.37s
✅ JSON eslint-plugin-jsonc 23 0 0 3.13s
✅ JSON jsonlint 21 0 0.27s
✅ JSON v8r 23 0 18.03s
⚠️ MARKDOWN markdownlint 313 0 232 8.8s
✅ MARKDOWN markdown-link-check 313 0 6.76s
✅ MARKDOWN markdown-table-formatter 313 0 0 24.79s
✅ OPENAPI spectral 1 0 1.86s
⚠️ PYTHON bandit 188 57 2.77s
✅ PYTHON black 188 0 0 6.03s
✅ PYTHON flake8 188 0 2.41s
✅ PYTHON isort 188 0 0 1.02s
✅ PYTHON mypy 188 0 10.68s
✅ PYTHON pylint 188 0 17.23s
⚠️ PYTHON pyright 188 251 21.73s
✅ PYTHON ruff 188 0 0 0.6s
✅ REPOSITORY checkov yes no 44.77s
✅ REPOSITORY git_diff yes no 0.47s
✅ REPOSITORY secretlint yes no 23.02s
✅ REPOSITORY trivy yes no 36.57s
✅ SPELL cspell 629 0 34.76s
⚠️ SPELL vale 222 59 48.89s
✅ XML xmllint 3 0 0 0.45s
✅ YAML prettier 157 0 0 6.68s
✅ YAML v8r 99 0 178.99s
✅ YAML yamllint 158 0 1.97s

See detailed report in MegaLinter reports

MegaLinter is graciously provided by OX Security

nvuillam avatar Sep 15 '22 22:09 nvuillam

How is it going? What is blocking it?

bdovaz avatar Dec 08 '22 11:12 bdovaz

@bdovaz memory crash within the docker image... really hard to debug :/ but you can try with temp docker image generated by CI job

nvuillam avatar Dec 18 '22 23:12 nvuillam

image

:/

nvuillam avatar Dec 20 '22 15:12 nvuillam

🦙 MegaLinter status: ⚠️ WARNING

Descriptor Linter Files Fixed Errors Elapsed time
✅ BASH bash-exec 6 0 0.01s
✅ BASH shellcheck 6 0 0.13s
✅ BASH shfmt 6 0 0 0.04s
✅ COPYPASTE jscpd yes no 2.63s
✅ DOCKERFILE hadolint 117 0 14.49s
✅ JSON eslint-plugin-jsonc 23 0 0 1.67s
✅ JSON jsonlint 21 0 0.18s
✅ JSON npm-package-json-lint yes no 0.6s
✅ JSON v8r 23 0 15.49s
⚠️ MARKDOWN markdownlint 313 2 232 5.66s
✅ MARKDOWN markdown-link-check 313 0 5.36s
✅ MARKDOWN markdown-table-formatter 313 2 0 17.2s
✅ OPENAPI spectral 1 0 1.26s
⚠️ PYTHON bandit 188 57 2.07s
✅ PYTHON black 188 0 0 3.75s
✅ PYTHON flake8 188 0 1.8s
✅ PYTHON isort 188 0 0 0.45s
✅ PYTHON mypy 188 0 7.6s
✅ PYTHON pylint 188 0 11.27s
⚠️ PYTHON pyright 188 251 15.13s
✅ PYTHON ruff 188 0 0 0.1s
✅ REPOSITORY checkov yes no 30.76s
⚠️ REPOSITORY devskim yes 1145 4.93s
✅ REPOSITORY dustilock yes no 1.97s
✅ REPOSITORY git_diff yes no 0.04s
✅ REPOSITORY secretlint yes no 12.24s
✅ REPOSITORY syft yes no 1.11s
✅ REPOSITORY trivy yes no 24.51s
✅ SPELL cspell 629 0 21.27s
⚠️ SPELL vale 222 59 34.42s
✅ XML xmllint 3 0 0 0.03s
✅ YAML prettier 157 0 0 4.11s
✅ YAML v8r 99 0 125.75s
✅ YAML yamllint 158 0 1.58s

See detailed report in MegaLinter reports

You could have same capabilities but better runtime performances if you request a new MegaLinter flavor.

MegaLinter is graciously provided by OX Security

nvuillam avatar Dec 22 '22 16:12 nvuillam

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

If you think this pull request should stay open, please remove the O: stale 🤖 label or comment on the pull request.

github-actions[bot] avatar Jan 22 '23 01:01 github-actions[bot]

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

If you think this pull request should stay open, please remove the O: stale 🤖 label or comment on the pull request.

github-actions[bot] avatar Feb 22 '23 00:02 github-actions[bot]

@nvuillam can you make a rebase? To at least check from time to time if this problem has been solved.

I would do it myself but I have doubts with utils.py and I prefer you to solve it.

bdovaz avatar Mar 26 '23 16:03 bdovaz

@bdovaz done :)

nvuillam avatar Mar 26 '23 17:03 nvuillam

@nvuillam Is it just me or seeing the result of the jobs, the random error that occurred no longer exists?

bdovaz avatar Apr 12 '23 17:04 bdovaz

@nvuillam Is it just me or seeing the result of the jobs, the random error that occurred no longer exists?

ping @nvuillam

bdovaz avatar Apr 18 '23 10:04 bdovaz

The error was not random... it was always and hard to diagnose its source ^^

nvuillam avatar Apr 18 '23 10:04 nvuillam

Not crashing indeed ! But did i rebuild?

nvuillam avatar Apr 18 '23 10:04 nvuillam

/build

Command run output Build command workflow started. Installing dependencies Running script ./build.sh Build command workflow completed without updating files.

nvuillam avatar Apr 18 '23 10:04 nvuillam

@bdovaz I have a good feeling about this one... :D :D

nvuillam avatar Apr 19 '23 21:04 nvuillam

@bdovaz @echoix @Kurt-von-Laven

Now I'm kind a afraid to release a new version... this PR is potentially very impacting, if you have some time please use beta versions in your repos to make sure that it still works well with relative files :) ( I'll obviously do the same on my side ^^ )

nvuillam avatar Apr 19 '23 21:04 nvuillam

You could release a RC in the weekend and look at the number of pulls the following week to make sure that there was enough pulls.

echoix avatar Apr 19 '23 21:04 echoix

Thanks for the heads up, @nvuillam. I tried the documentation, dotnet, javascript, and python flavors of the beta version on all of our repositories and encountered three issues. I am listing them all here for now since the second and third seem like they could potentially be related, but I am happy to file issues about these when I have more time tomorrow. The third issue is a preexisting issue that was made more visible by #2455, because previously ESLint silently didn't run at all locally.

  1. CSharpier is broken; I am curious whether anyone else encounters this issue:

    ❌ Linted [CSHARP] files with [csharpier]: Found 1 error(s) - (1.18s)
    --Error detail:
    Run "dotnet tool restore" to make the "dotnet-csharpier" command available.
    
    Unable to get number of errors with regex_number and Issues found: ([0-9]+) in .* files
    
  2. CSpell is broken when importing dictionaries that aren't bundled:

    ❌ Linted [SPELL] files with [cspell]: Found 1 error(s) - (18.84s)
    --Error detail:
    Configuration Error: Failed to read config file: "/tmp/lint/@cspell/dict-medicalterms/cspell-ext.json"
    CSpell: Files checked: 0, Issues found: 0 in 0 files
    
    ❌ Error(s) have been found during linting
    

    Our cspell.config.yaml contains:

    import:
      - "@cspell/dict-medicalterms/cspell-ext.json"
    

    Our .mega-linter.yaml contains:

    SPELL_CSPELL_CONFIG_FILE: LINTER_DEFAULT
    SPELL_CSPELL_PRE_COMMANDS:
      - command: npm install @cspell/[email protected]
    
  3. In our Yarn TypeScript projects, there is one error per file of the following form:

    ❌ Linted [TYPESCRIPT] files with [eslint]
    --Error detail:
    
    /tmp/lint/some_file.ts
      0:0  error  Parsing error: File '@tsconfig/node18-strictest-esm/tsconfig.json' not found
    

    Our tsconfig.json contains:

    {
      "extends": "@tsconfig/node18-strictest-esm/tsconfig.json"
    }
    

    Our package.json contains:

    {
      "devDependencies": {
        "@tsconfig/node18-strictest-esm": "1.0.1"
      }
    }
    

    Our .eslintrc.yaml is:

    root: true
    extends:
      - eslint:recommended
      - plugin:@typescript-eslint/recommended
      - prettier
    parser: "@typescript-eslint/parser"
    parserOptions:
      project:
        - tsconfig.json
    plugins:
      - "@typescript-eslint"
    env:
      node: true
    

Kurt-von-Laven avatar Apr 20 '23 11:04 Kurt-von-Laven

If it makes you feel any better, passing relative file paths fixed the error originally reported in #1572, getting ESLint running in list_of_files mode for npm projects and unblocking running ESLint in list_of_files mode for Yarn PnP projects.

Kurt-von-Laven avatar Apr 27 '23 08:04 Kurt-von-Laven

@Kurt-von-Laven I'm trying to fix that in #2601 ... the idea is the following:

  • check if PRE_COMMANDS contain "npm" or "yarn"
  • if yes:
    • copy /node_deps into workspace+"node_modules"
    • Add workspace+"node_modules" in PATH
    • run the PRE_COMMANDS

Do you think it could work ? ^^

nvuillam avatar Apr 30 '23 16:04 nvuillam