Skip to content

Commit

Permalink
Allow to use value any to always activate a linter who as a **_DIRE…
Browse files Browse the repository at this point in the history
…CTORY** variable

Example: `KUBERNETES_DIRECTORY: any`
Fixes #2873
Co-authored-by: onepushmain <onepushmain@users.noreply.github.com>
  • Loading branch information
nvuillam and onepushmain committed Nov 1, 2023
1 parent 0d112d4 commit 2cfce9c
Show file tree
Hide file tree
Showing 14 changed files with 20,485 additions and 20,469 deletions.
4 changes: 3 additions & 1 deletion .automation/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1618,7 +1618,8 @@ def process_type(linters_by_type, type1, type_label, linters_tables_md):

if linter.files_sub_directory is not None:
linter_doc_md += [
f"| {linter.descriptor_id}_DIRECTORY | Directory containing {linter.descriptor_id} files "
f"| {linter.descriptor_id}_DIRECTORY | Directory containing {linter.descriptor_id} files"
" (use `any` to always activate the linter)"
f"| `{linter.files_sub_directory}` |"
]
add_in_config_schema_file(
Expand All @@ -1628,6 +1629,7 @@ def process_type(linters_by_type, type1, type_label, linters_tables_md):
{
"$id": f"#/properties/{linter.name}_DIRECTORY",
"type": "string",
"description": f'Directory that must be found to activate linter. Use value "any" to always activate',
"title": f"{title_prefix}{linter.name}: Directory containing {linter.descriptor_id} files",
"default": linter.files_sub_directory,
},
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-linter.yml file, or with `oxsecurity/megalinter:beta` docker image

- Allow to use value `any` to always activate a linter who as a **_DIRECTORY** variable. Example: `KUBERNETES_DIRECTORY: any`

- Linter versions upgrades
- [protolint](https://github.com/yoheimuta/protolint) from 0.46.2 to **0.46.3** on 2023-10-29
- [checkov](https://www.checkov.io/) from 3.0.12 to **3.0.13** on 2023-10-30
Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/action_actionlint.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Static checker for GitHub Actions workflow files
| ACTION_ACTIONLINT_DISABLE_ERRORS | Run linter but consider errors as warnings | `false` |
| ACTION_ACTIONLINT_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | `0` |
| ACTION_ACTIONLINT_CLI_EXECUTABLE | Override CLI executable | `['actionlint']` |
| ACTION_DIRECTORY | Directory containing ACTION files | `.github/workflows` |
| ACTION_DIRECTORY | Directory containing ACTION files (use `any` to always activate the linter) | `.github/workflows` |

## MegaLinter Flavours

Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/ansible_ansible_lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ description: How to use ansible-lint (configure, ignore files, ignore errors, he
| ANSIBLE_ANSIBLE_LINT_DISABLE_ERRORS | Run linter but consider errors as warnings | `false` |
| ANSIBLE_ANSIBLE_LINT_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | `0` |
| ANSIBLE_ANSIBLE_LINT_CLI_EXECUTABLE | Override CLI executable | `['ansible-lint']` |
| ANSIBLE_DIRECTORY | Directory containing ANSIBLE files | `ansible` |
| ANSIBLE_DIRECTORY | Directory containing ANSIBLE files (use `any` to always activate the linter) | `ansible` |

## MegaLinter Flavours

Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/kubernetes_helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ description: How to use helm (configure, ignore files, ignore errors, help & ver
| KUBERNETES_HELM_DISABLE_ERRORS | Run linter but consider errors as warnings | `false` |
| KUBERNETES_HELM_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | `0` |
| KUBERNETES_HELM_CLI_EXECUTABLE | Override CLI executable | `['helm']` |
| KUBERNETES_DIRECTORY | Directory containing KUBERNETES files | `` |
| KUBERNETES_DIRECTORY | Directory containing KUBERNETES files (use `any` to always activate the linter) | `` |

## MegaLinter Flavours

Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/kubernetes_kubeconform.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ description: How to use kubeconform (configure, ignore files, ignore errors, hel
| KUBERNETES_KUBECONFORM_DISABLE_ERRORS | Run linter but consider errors as warnings | `false` |
| KUBERNETES_KUBECONFORM_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | `0` |
| KUBERNETES_KUBECONFORM_CLI_EXECUTABLE | Override CLI executable | `['kubeconform']` |
| KUBERNETES_DIRECTORY | Directory containing KUBERNETES files | `kubernetes` |
| KUBERNETES_DIRECTORY | Directory containing KUBERNETES files (use `any` to always activate the linter) | `kubernetes` |

## MegaLinter Flavours

Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/kubernetes_kubescape.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ description: How to use kubescape (configure, ignore files, ignore errors, help
| KUBERNETES_KUBESCAPE_DISABLE_ERRORS | Run linter but consider errors as warnings | `false` |
| KUBERNETES_KUBESCAPE_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | `0` |
| KUBERNETES_KUBESCAPE_CLI_EXECUTABLE | Override CLI executable | `['kubescape']` |
| KUBERNETES_DIRECTORY | Directory containing KUBERNETES files | `` |
| KUBERNETES_DIRECTORY | Directory containing KUBERNETES files (use `any` to always activate the linter) | `` |

## IDE Integration

Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/powershell_powershell.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ description: How to use powershell (configure, ignore files, ignore errors, help
| POWERSHELL_POWERSHELL_RULES_PATH | Path where to find linter configuration file | Workspace folder, then MegaLinter default rules |
| POWERSHELL_POWERSHELL_DISABLE_ERRORS | Run linter but consider errors as warnings | `false` |
| POWERSHELL_POWERSHELL_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | `0` |
| POWERSHELL_POWERSHELL_CLI_EXECUTABLE | Override CLI executable | `['pwsh']` |
| POWERSHELL_POWERSHELL_CLI_EXECUTABLE | Override CLI executable | `['powershell']` |

## IDE Integration

Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/powershell_powershell_formatter.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ description: How to use powershell_formatter (configure, ignore files, ignore er
| POWERSHELL_POWERSHELL_FORMATTER_RULES_PATH | Path where to find linter configuration file | Workspace folder, then MegaLinter default rules |
| POWERSHELL_POWERSHELL_FORMATTER_DISABLE_ERRORS | Run linter but consider errors as warnings | `true` |
| POWERSHELL_POWERSHELL_FORMATTER_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | `0` |
| POWERSHELL_POWERSHELL_FORMATTER_CLI_EXECUTABLE | Override CLI executable | `['pwsh']` |
| POWERSHELL_POWERSHELL_FORMATTER_CLI_EXECUTABLE | Override CLI executable | `['powershell']` |

## IDE Integration

Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/salesforce_sfdx_scanner_apex.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ See more details in [Help](#help-content)
| SALESFORCE_SFDX_SCANNER_APEX_DISABLE_ERRORS | Run linter but consider errors as warnings | `false` |
| SALESFORCE_SFDX_SCANNER_APEX_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | `0` |
| SALESFORCE_SFDX_SCANNER_APEX_CLI_EXECUTABLE | Override CLI executable | `['sfdx']` |
| SALESFORCE_DIRECTORY | Directory containing SALESFORCE files | `force-app` |
| SALESFORCE_DIRECTORY | Directory containing SALESFORCE files (use `any` to always activate the linter) | `force-app` |

## IDE Integration

Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/salesforce_sfdx_scanner_aura.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ See more details in [Help](#help-content)
| SALESFORCE_SFDX_SCANNER_AURA_DISABLE_ERRORS | Run linter but consider errors as warnings | `false` |
| SALESFORCE_SFDX_SCANNER_AURA_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | `0` |
| SALESFORCE_SFDX_SCANNER_AURA_CLI_EXECUTABLE | Override CLI executable | `['sfdx']` |
| SALESFORCE_DIRECTORY | Directory containing SALESFORCE files | `force-app` |
| SALESFORCE_DIRECTORY | Directory containing SALESFORCE files (use `any` to always activate the linter) | `force-app` |

## IDE Integration

Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/salesforce_sfdx_scanner_lwc.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ See more details in [Help](#help-content)
| SALESFORCE_SFDX_SCANNER_LWC_DISABLE_ERRORS | Run linter but consider errors as warnings | `false` |
| SALESFORCE_SFDX_SCANNER_LWC_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | `0` |
| SALESFORCE_SFDX_SCANNER_LWC_CLI_EXECUTABLE | Override CLI executable | `['sfdx']` |
| SALESFORCE_DIRECTORY | Directory containing SALESFORCE files | `force-app` |
| SALESFORCE_DIRECTORY | Directory containing SALESFORCE files (use `any` to always activate the linter) | `force-app` |

## IDE Integration

Expand Down
10 changes: 7 additions & 3 deletions megalinter/Linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,17 @@ def __init__(self, params=None, linter_config=None):
f"{self.descriptor_id}_DIRECTORY",
self.files_sub_directory,
)
if not os.path.isdir(
if self.files_sub_directory == 'any':
logging.info(
f"[Activation] {self.name} skip check of directory as value set to \"any\""
)
elif not os.path.isdir(
self.workspace + os.path.sep + self.files_sub_directory
):
self.is_active = False
logging.debug(
logging.info(
f"[Activation] {self.name} has been set inactive, as subdirectory has not been found:"
f" {self.files_sub_directory}"
f" {self.files_sub_directory} (set value \"any\" to always activate)"
)

# Some linters require a file to be existing, else they're deactivated ( ex: .editorconfig )
Expand Down

0 comments on commit 2cfce9c

Please sign in to comment.