Skip to content

Commit

Permalink
Fix SPELL_VALE_CONFIG_FILE not working (#3409)
Browse files Browse the repository at this point in the history
Co-authored-by: Sam Chorlton <[email protected]>
(handle the override of linter CONFIG_FILE if the linter is activated only if some files are found)

Co-authored-by: nvuillam <[email protected]>
  • Loading branch information
nvuillam and nvuillam authored Mar 9, 2024
1 parent 2d0e209 commit df36617
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l
- Trivy: use `misconfig` instead of the deprecated `config` scanner, updating the default arguments
- Update calls to sfdx-scanner to output a CSV file for Aura & LWC
- Kics: fixed error count in the summary table
- Fix SPELL_VALE_CONFIG_FILE not working (handle the override of linter CONFIG_FILE if the linter is activated only if some files are found)

- Doc
- Removed obsolete warning for semgrep as the issue has been fixed
Expand Down
13 changes: 13 additions & 0 deletions megalinter/Linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,18 +455,22 @@ def load_config_vars(self, params):
self.config_file_name = config.get(
self.request_id, self.name + "_CONFIG_FILE"
)
self.update_active_if_file_found()
elif config.exists(self.request_id, self.descriptor_id + "_CONFIG_FILE"):
self.config_file_name = config.get(
self.request_id, self.descriptor_id + "_CONFIG_FILE"
)
self.update_active_if_file_found()
elif config.exists(self.request_id, self.name + "_FILE_NAME"):
self.config_file_name = config.get(
self.request_id, self.name + "_FILE_NAME"
)
self.update_active_if_file_found()
elif config.exists(self.request_id, self.descriptor_id + "_FILE_NAME"):
self.config_file_name = config.get(
self.request_id, self.descriptor_id + "_FILE_NAME"
)
self.update_active_if_file_found()
# Ignore file name: try first NAME + _FILE_NAME, then LANGUAGE + _FILE_NAME
if self.cli_lint_ignore_arg_name is not None:
if config.exists(self.request_id, self.name + "_IGNORE_FILE"):
Expand Down Expand Up @@ -741,6 +745,15 @@ def load_config_vars(self, params):
self.request_id, self.name + "_DOCKER_IMAGE_VERSION"
)

# If linter is activated only if some file is found, and config file has been overridden
# -> add it to the files to check
def update_active_if_file_found(self):
if (
len(self.active_only_if_file_found) > 0
and self.config_file_name not in self.active_only_if_file_found
):
self.active_only_if_file_found.append(self.config_file_name)

# Processes the linter
def run(self):
self.start_perf = perf_counter()
Expand Down

0 comments on commit df36617

Please sign in to comment.