Commit graph

139 commits

Author SHA1 Message Date
Holt Skinner
469f30eb53
feat: add nbqa linter for jupyter notebooks (#6240) 2024-12-20 19:13:16 +00:00
Andre Klärner
ec05515e93
fix: ensure setting /github/workdir as Git safe directory works always (#6242)
When running super-linter on in a self hosted runner based on Action
Runner Controller in K8s container mode the /github/home directory is
not neccesarily mounted. But since we expect this directory to exist
super-linter fails to set /github/workspace as a Git safe directory:

    2024-10-04 17:58:37 [INFO]   Successfully validated GITHUB_WORKSPACE: /github/workspace
    2024-10-04 17:58:37 [DEBUG]   Configuring Git safe directories
    2024-10-04 17:58:37 [DEBUG]   Set /github/workspace as a Git safe directory
    error: could not lock config file /github/home/.gitconfig: No such file or directory
    2024-10-04 17:58:37 [FATAL]   Cannot configure /github/workspace as a Git safe directory.

Making sure this directory exists in container image ensures that under
no circumstances we can fail - if the action runner provides
/github/home it will be mounted over, and if not we provide a directory
where git can actually create the new .gitconfig.

This also defaults the HOME environment variable to /github/home as it
is the default in most places. So if somebody decides to override HOME
they are also expected to ensure that this directory exists (or is a
volume mount)
2024-12-12 15:44:28 +00:00
George L. Yermulnik
d929d049cb
fix: make git conflict markers check more precise (#6379)
The https://github.com/super-linter/super-linter/pull/6113 introduced
new Git merge conflicts linter check, that is error prone in some
conditions (see screenshot).

This PR adjusts this check to be more precise and exact in a way that
all three markers should be found to identify check as failed.
Additionally improve Git merge conflict markers matchers.

Co-authored-by: Marco Ferrari <ferrari.marco@gmail.com>
2024-12-03 15:03:44 +00:00
Marco Ferrari
6b60f4c968
fix: define command options function before use (#6375)
Define functions in linterCommands.sh to avoid the need of exporting
them. Without this fix, a command that sourced linterCommands.sh would
not be able to find these functions, such as AddOptionsToCommand.

Fix #6372
2024-11-27 14:33:40 +01:00
Marco Ferrari
ffccf2d49d
fix: downgrade npm-groovy-lint to 15.0.0 (#6373)
Fix #6371

npm-groovy-lint > 15.0.0 is impacted by:

- https://github.com/nvuillam/npm-groovy-lint/issues/428
- https://github.com/nvuillam/npm-groovy-lint/issues/422
2024-11-27 11:57:54 +01:00
Marco Ferrari
6c2f03ffb4
chore: prepare tests for updates (#6279)
Prepare tests for linters and formatter updates.
2024-11-14 15:29:44 +01:00
Marco Ferrari
fc34cb53d9
chore: shorten linter versions (#6176)
Shorten the linter versions file by keeping only the version string for
each linter, instead of the entire output of the version command
2024-10-14 18:43:10 +02:00
Marco Ferrari
5d6e3fcecc
feat: lint commit messages with commitlint (#6118)
Add support to run Commitlint against commit messages. It supports the
current modes:

- Lint the commit message of the last commit
- Lint the commit messages of the pushed commits in case there is more
  than one pushed commit

This commit also removes stuff that we used to run commitlint as a
standalone tool because we can now use the commitlint instance that
Super-linter ships:

- lint-commit steps in lint-commit the GitHub Actions workflow
- lint-commit Make target
- commitlint and its dependencies in package.json and package-lock.json
2024-09-19 08:53:13 +00:00
Marco Ferrari
170cabf92b
chore: devcontainer, docs, prettier config (#6119)
- Update devcontainer by setting Prettier as a formatter only for
  supported languages.
- Install only the VS Code extensions that we need for Super-linter
  development.
- Remove the devcontainer as soon as it's not needed to avoid leaving
  leftovers behind.
- Enable proseWrap in Prettier configuration.
- Update documentation about how to configure new linters.
- Fix linting issues.
2024-09-13 14:37:48 +02:00
Marco Ferrari
72a4884f7a
chore: manage php dependencies (#6139)
- Install PHP dependencies using composer
- Watch composer dependency updates with Dependabot
2024-09-13 08:08:39 +02:00
Marco Ferrari
e0d8b4fb2f
feat: implement a linter to check git conflicts (#6113)
Implement a linter to check if files contain Git conflict
markers or whitespace errors.
2024-09-05 08:02:36 +02:00
Marco Ferrari
94920ffcc7
feat: optionally remove color codes from output (#6095)
If REMOVE_ANSI_COLOR_CODES_FROM_OUTPUT is set to true, remove ANSI color
codes from linters stdout and stderr files, and from the Super-linter
log file.

Close #5540
2024-08-31 19:50:00 +02:00
Marco Ferrari
05d4d4e128
feat: allow passing custom options to rust clippy (#6094)
Define the RUST_CLIPPY_COMMAND_OPTIONS variable to allow passing
arbitrary options to the command that runs RUST_CLIPPY.

Fix the ARM test case that just failed because of its apiVersion just
expired.

Close #4001
2024-08-31 14:51:28 +02:00
Marco Ferrari
ad0ff68c52
fix: correctly load custom linter commands (#6085)
Linters affected:

- actionlint
- Kubeconform
- Perlcritic

Also:

- Update package-lock.json to update some vulnerable dependencies.
- Mount dependency files to where the dependency manager expects them so
  it's easier to update vulnerable dependencies.

Fix #6084
2024-08-30 12:03:08 +02:00
Nito Buendia
5b13acee46
feat: add pyink as a Python formatter (#6083) 2024-08-27 15:00:51 +00:00
Marco Ferrari
11d4aac68c
chore: format super-linter summaries (#6063)
Run Prettier to format the Super-linter summary file to produce
summaries with consistent formatting.
2024-08-25 19:43:33 +02:00
Marco Ferrari
9f193cc3c0
feat: format JSONC and JSON5 with prettier (#6041) 2024-08-16 17:15:05 +02:00
Marco Ferrari
8ceae0f304
feat: lint and format dotnet solutions (#6039)
Close #736
2024-08-16 16:23:52 +02:00
Marco Ferrari
1d12a31fce
feat: prettier for additional languages (#6025)
- CSS, Sass, SCSS
- HTML
- JSON
- JSX
- GraphQL
- Vue
- YAML
2024-08-15 11:46:02 +02:00
Marco Ferrari
2664cb3b19
chore: fix formatting issues (#6028) 2024-08-15 10:21:26 +02:00
Marco Ferrari
2f0ac20566
fix: avoid concurrent edits to the same file (#6027)
Reduce the number of processes to 1 if at least one FIX_xxxx variable is
set to true. This avoids that Parallel runs multiple processes that
might edit the same file at the same time.
2024-08-14 22:20:56 +02:00
Marco Ferrari
48d5391b7b
fix!: remove sql-lint (#5991)
sql-lint is unmaintained, and its dependencies are impacted by several
vulnerabilities.
2024-08-14 17:30:46 +02:00
Marco Ferrari
8dc1475a3a
feat: allow customizing gitleaks log level (#5993) 2024-08-14 14:54:16 +02:00
Marco Ferrari
4854e774f3
chore: disable dotnet telemetry (#6016) 2024-08-13 16:12:32 +02:00
Marco Ferrari
0c6e9a5778
chore: remove test leftovers before running fix test (#5995)
- Remove test leftovers before initializing the workspace
  against which fix mode tests run. This prevents ownership issues.
- Pass container image build metadata as outputs of the container image
  build job so we can include the validate-container-image-labels target
  as other test target when we build the test matrix.
- Manually include the 'test' target when building the test suite matrix
  so we run it as part of the test suite to ensure that tests don't
  pollute each other's working directory.

Fix #5994
2024-08-12 18:01:40 +02:00
Marco Ferrari
91dc6d7234
fix: add missing fix mode options and test cases (#5987)
- Add missing fix mode options for: CLANG_FORMAT, ENV,
  GOOGLE_JAVA_FORMAT, NATURAL_LANGUAGE, PYTHON_ISORT, RUST_CLIPPY.
- Refactor linter tests to make them shorter because there's no need to
  have big test files.
- Refactor 'bad' linter tests for linters that support fix mode so they
  contain only automatically fixable issues. This is needed to avoid
  adding another set of 'bad' linter tests for fix mode.
- Provide configuration files for linters that support fix mode and for
  which the default configuration is not suitable to enable fix mode:
  ansible-lint, ESLint, golangci-lint.
- Add a test case for linter commands options for linters that support
  fix mode, to ensure that fix mode and check-only mode options have
  been defined.
- Refactor the fix mode test to check if linters actually applied
  modifications to files.
- Update documentation about adding test cases for linters that support
  fix mode.
- Don't exit with a fatal error if VALIDATE_xxx is false when testing
  fix mode because not all linters support fix mode. To enable this, set
  the new FIX_MODE_TEST_CASE_RUN variable to true.
2024-08-12 12:31:38 +02:00
Niel Markwick
ea16cd9a1b
fix: add RENOVATE_X_IGNORE_RE2 env var to remove warning (#5986)
Renovate has an optional requirement for the RE2 package, and will warn if
it is not present.

Setting env variable RENOVATE_X_IGNORE_RE2=true will hide this warning.
(see https://github.com/renovatebot/renovate/pull/21391)
2024-08-12 11:14:51 +02:00
Marco Ferrari
40410c2d60
fix: use cargo clippy instead of cargo-clippy (#5988)
The cargo-clippy command has been depreacted since Cargo
v1.78.0. This is needed to unblock the implementation of fix mode.
2024-08-11 23:18:33 +02:00
Marco Ferrari
6fdc091361
feat: local fix mode (#5978)
Certain linters and formatters support fixing linting and formatting
issues (fix mode). Before this change, Super-linter runs linters and
formatters in a mode that doesn't modify the source code in any way
(check only mode).

With this change, Super-linter supports running linters and formatters
in fix mode if explicitly requested by the configuration. If the
configuration includes a variable named FIX_<language_name>,
Super-linters modifies the command to run the linter or formatter for
<language_name> to enable fix mode.

The modifications to the linter or formatter command that Super-linter
applies depend on what is the default for a particular linter: it either
removes or adds options to the command to run the linter or formatter.
2024-08-07 15:36:16 +02:00
Marco Ferrari
633b8af60d
fix: add missing rspec dependencies (#5982)
rubocop-rspec >= 3.0.0 doesn't install some gems by default, so we
install them manually.

Fix #5980
2024-08-06 22:29:45 +02:00
Marco Ferrari
10e132a8f7
chore: add tests for linter rules path corner case (#5981)
Add test cases for LINTER_RULES_PATH corner cases: . and /
2024-08-06 22:02:39 +02:00
Marco Ferrari
0dbe144336
feat: support ignore_gitignored_files with jscpd (#5958)
Add the --gitignore option to LINTER_COMMANDS_ARRAY_JSCPD when
IGNORE_GITIGNORED_FILES=true. Users can also set the gitignore options
in the Jscpd configuration file, but with this change we make Jscpd
automatically respecting that.
2024-08-05 10:15:40 +02:00
Marco Ferrari
16dbf17306
chore: add linter commands tests (#5957) 2024-08-05 09:55:58 +02:00
Marco Ferrari
14a6ee6da6
chore: move rules vars to a dedicated file (#5946) 2024-08-05 08:56:56 +02:00
Marco Ferrari
c46346c774
chore: remove clippy script, run clippy directly (#5953)
Remove clippy.sh script and run cargo-clippy directly. The script was
needed because when we introduced cargo-clippy, Super-linter didn't have
a way to customize the working directory when running linters and
formatters. Now, we can use GNU Parallel to handle that case.

This will unblock the work to do to implement #4001 (pass custom options
to cargo-clippy).
2024-08-02 13:24:43 +02:00
Marco Ferrari
928972feeb
fix: adjust previous commit id on merge commits (#5950)
- When a commit is a merge commit, adjust the revision so that it
  selects the correct parent.
- Add relevant tests.
- Extract the logic to initialize a Git repository for tests in a
  dedicated function.

Fix #5941
2024-08-02 10:37:27 +02:00
Marco Ferrari
d9592327c6
chore: extract language array definition (#5945)
Move LANGUAGE_ARRAY definition and initialization to a dedicated file
(globals/languages.sh) so we can source it in different places without
having to source the whole linter.sh
2024-07-31 17:00:41 +02:00
Shop-kins
eec862d0ea
fix: update pylint to ignore import-errors (#5927)
-re-instates previous super-linter pylint functionality

-ignoring import errors is desired as super-linter does not
 support installing dependencies as it runs

-creates a new test case file for confirming
 import-errors are disabled this consists of a 3rd
 party import and a basic usage
2024-07-31 09:27:11 +02:00
Marco Ferrari
ef57e132e1
fix: avoid duplicated content in summary (#5939)
- Remove the previous summary file is present to avoid showing stale
  contents from old summaries.
- Extract the logic to write summary heading and lines to dedicated
  functions in output.sh to make it easier adding new formats in the
  future.
2024-07-30 08:35:14 +02:00
Marco Ferrari
78ed3ef5fc
fix: store outputs in the main output directory (#5899)
- Store Super-linter outputs in the main output directory.
- Update README with a few fixes and details about outputs.
- Add missing test cases for when the configuration didn't enable any
  output.
2024-07-28 21:34:40 +02:00
Marco Ferrari
70e0239117
chore: remove duplicated configuration files (#5928)
Remove duplicated linter configuration files when they match with the
default ones..
2024-07-28 19:43:03 +02:00
Marco Ferrari
2daf461143
feat: allow using both prettier and standardjs (#5679)
- Allow using both Prettier and StandardJS at the same time by removing
  JAVASCRIPT_DEFAULT_STYLE and TYPESCRIPT_DEFAULT_STYLE
  configuration variables. They create a confusing corner case that
  Super-linter already handles with its core logic that's in place to
  enable and disable linters.
- Document VALIDATE_JAVASCRIPT_PRETTIER and VALIDATE_TYPESCRIPT_PRETTIER
  because they were missing from the README.
- Add missing TYPESCRIPT_PRETTIER tests.
2024-07-19 05:04:43 +00:00
Marco Ferrari
d2d73347d3
chore: split validation logic in smaller functions (#5892)
- Move USE_FIND_ALGORITHM and VALIDATE_ALL_CODEBASE validation in a
  dedicated function (ValidateFindMode).
- Move ANSIBLE_DIRECTORY validation to a dedicated function
  (ValidateAnsibleDirectory).
- Move VALIDATE_xxxx variables validation to a dedicated function
  (ValidateValidationVariables).
- Mark ANY_SET, ANY_TRUE, ANY_FALSE as local because we don't need to
  reference them anywhere outside ValidateValidationVariables.
- Add some debug statements in validation functions.
- Merge the loops to initialize VALIDATE_xxx variables and to print
  enable/disable language debug messages.
- Add tests for these validation functions.
- Add test start message for all tests.
2024-07-16 08:22:45 +00:00
Chongyi Zheng
d9d19095ec
chore: bump alpine image to 3.20 and php to 8.3.x (#5863) 2024-07-15 09:52:42 +00:00
Marco Ferrari
57c86588c3
feat: write github actions step summary (#5867)
This also removes an unneeded textlint configuration file because it
matches with the default one.

Close #5650
2024-07-11 08:01:11 +00:00
Marco Ferrari
c770a8d253
feat: enable dotenv-linter for slim images (#5868)
Set up dotenv-linter for the slim image, and not only for the standard
image because it doesn't have dependencies on the Rust SDK, and weights
less than 10MB.
2024-07-10 15:50:15 +02:00
Marco Ferrari
256b22786d
chore: fix linting errors (#5843)
Close #5841
Close #5842
2024-07-05 10:18:22 +02:00
Marco Ferrari
94bb3f5563
feat: save super-linter output if requested (#5806)
- New SAVE_SUPER_LINTER_OUTPUT variable. When set to true,
  saves super-linter output to ${DEFAULT_WORKSPACE}/${SUPER_LINTER_OUTPUT_DIRECTORY_NAME}
- New SUPER_LINTER_OUTPUT_DIRECTORY_NAME variable to set the output
  directory name instide the default workspace.

Close #5774
2024-07-01 14:50:52 +02:00
Marco Ferrari
d74351fda7
feat: add the kustomize binary for checkov (#5763)
Checkov needs the kustomize binary to enable related checks, otherwise
these checks are silently skipped.

Ref https://www.checkov.io/7.Scan%20Examples/Kustomize.html
2024-06-27 19:03:16 +02:00
Marco Ferrari
cef17760de
feat: configure github server url (#5792)
Allow the configuration of the GitHub server URL, and add some
validation rules that check for common misconfigurations.

Close #5572
2024-06-21 08:54:19 +02:00