Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue #3963 #3974

Merged
merged 11 commits into from
Nov 11, 2024
Merged

Fix for issue #3963 #3974

merged 11 commits into from
Nov 11, 2024

Conversation

llaville
Copy link
Collaborator

@llaville llaville commented Sep 8, 2024

Fixes #3963

Readiness Checklist

Author/Contributor

  • Add entry to the CHANGELOG listing the change and linking to the corresponding issue (if appropriate)
  • If documentation is needed for this change, has that been included in this pull request

Reviewing Maintainer

  • Label as breaking if this is a large fundamental change
  • Label as either automation, bug, documentation, enhancement, infrastructure, or performance

Copy link
Contributor

github-actions bot commented Sep 8, 2024

🦙 MegaLinter status: ⚠️ WARNING

Descriptor Linter Files Fixed Errors Elapsed time
✅ API spectral 1 0 1.77s
⚠️ BASH bash-exec 6 1 0.04s
✅ BASH shellcheck 6 0 0.23s
✅ BASH shfmt 6 0 0 0.85s
✅ COPYPASTE jscpd yes no 4.43s
✅ DOCKERFILE hadolint 128 0 24.34s
✅ JSON jsonlint 20 0 0.2s
✅ JSON v8r 22 0 32.43s
⚠️ MARKDOWN markdownlint 266 0 297 43.98s
✅ MARKDOWN markdown-table-formatter 266 0 0 137.42s
⚠️ PYTHON bandit 212 66 3.89s
✅ PYTHON black 212 0 0 6.42s
✅ PYTHON flake8 212 0 2.45s
✅ PYTHON isort 212 0 0 1.4s
✅ PYTHON mypy 212 0 16.74s
✅ PYTHON pylint 212 0 33.72s
✅ PYTHON ruff 212 0 0 0.51s
✅ REPOSITORY checkov yes no 37.91s
✅ REPOSITORY git_diff yes no 0.76s
⚠️ REPOSITORY grype yes 24 15.35s
✅ REPOSITORY secretlint yes no 15.23s
✅ REPOSITORY trivy yes no 31.91s
✅ REPOSITORY trivy-sbom yes no 0.36s
⚠️ REPOSITORY trufflehog yes 1 8.18s
✅ SPELL cspell 713 0 14.72s
⚠️ SPELL lychee 348 5 7.53s
✅ XML xmllint 3 0 0 1.02s
✅ YAML prettier 160 0 0 5.15s
✅ YAML v8r 102 0 193.02s
✅ YAML yamllint 161 0 3.38s

See detailed report in MegaLinter reports

MegaLinter is graciously provided by OX Security

@echoix
Copy link
Collaborator

echoix commented Sep 8, 2024

I'll do a rerun of the failed ones. They aren't always 100% non-flaky..

@llaville
Copy link
Collaborator Author

I'll do a rerun of the failed ones. They aren't always 100% non-flaky..

I've found origin of regression (introduced in my first commit, and fixed by second commit). Wait and see if CI is agree with my analysis, but locally it seems to be good !

Cross fingers ;-)

@llaville
Copy link
Collaborator Author

All seems ok except for saleforces_* linters (trivy scanner found vulnerabilities)

@echoix
Copy link
Collaborator

echoix commented Sep 10, 2024

All seems ok except for saleforces_* linters (trivy scanner found vulnerabilities)

They also appear in the auto update PR since yesterday

@echoix
Copy link
Collaborator

echoix commented Sep 10, 2024

All seems ok except for saleforces_* linters (trivy scanner found vulnerabilities)

Do you want it merged now ? If so, when ready, change the title to remove the Work in progress, and I'll do a final read and merge

@llaville
Copy link
Collaborator Author

All seems ok except for saleforces_* linters (trivy scanner found vulnerabilities)

Do you want it merged now ? If so, when ready, change the title to remove the Work in progress, and I'll do a final read and merge

I need to write some doc and changelog. I will do in next hours.

@llaville
Copy link
Collaborator Author

Finally found another problem. Need to investigate more. I'll be busy tomorrow, so I'll do it only thursday.

@llaville
Copy link
Collaborator Author

Finally, found it ! Now it's time for explains.

On my first approach and commit, I've introduced a test
fb1510a#diff-6edf526a9f6b62ef500e048620fd0d43bbc65957ed84e9033d2ff9f8f03206b4R259

that was usefull for PHPCSFIXER but add a regression for other linters.

So, I go back with second commit
0661847

It was an error, because even if it restored previous good behaviour for other linters, it won't work anymore for PHPCSFIXER.

My final version that works for all linters is :

  • extracted code that activate apply_fixes feature (more pretty and easy to debug) on new function def manage_apply_fixes(self, params)

That gave an extra debug log for each linter; for example :

[Activation] + PHP_PHPCSFIXER (PHP) was activated by ENABLE strategies
[Apply Fixes] is enabled for + PHP_PHPCSFIXER (PHP)
  • define default apply_fixes value to False and remove first if test condition that was source or problem

if self.cli_lint_fix_arg_name is None:

Last but not least, I've also :

  • added note on PHPCSFIXER about apply_fixes
  • added entry into CHANGELOG

That's all !

@github-actions github-actions bot removed the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Oct 13, 2024
@@ -20,6 +20,13 @@ description: How to use php-cs-fixer (configure, ignore files, ignore errors, he
- Enable php-cs-fixer by adding `PHP_PHPCSFIXER` in [ENABLE_LINTERS variable](https://megalinter.io/beta/configuration/#activation-and-deactivation)
- Disable php-cs-fixer by adding `PHP_PHPCSFIXER` in [DISABLE_LINTERS variable](https://megalinter.io/beta/configuration/#activation-and-deactivation)

- Enable **autofixes** by adding `PHP_PHPCSFIXER` in [APPLY_FIXES variable](https://megalinter.io/beta/configuration/#apply-fixes)

> [!NOTE]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@llaville this markdown file is generated, so if you need such text here, you need to define it in the descriptor YML file , in linter_text property :)

@@ -1260,12 +1273,14 @@ def build_lint_command(self, file=None) -> list:
# Add fix argument if defined
if self.apply_fixes is True and (
self.cli_lint_fix_arg_name is not None
or len(self.cli_lint_fix_remove_args) > 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@llaville that's too vague, I need to understand what you want to do here 🥺

@nvuillam nvuillam merged commit a01f80f into main Nov 11, 2024
123 of 129 checks passed
@nvuillam nvuillam deleted the fix/php-cs-fixer_apply_fixes branch November 11, 2024 13:45
@nvuillam
Copy link
Member

@llaville I just merged, please can you make another PR to fix the doc in linter_text descriptor property ? :)

@llaville
Copy link
Collaborator Author

@nvuillam new PR #4249 to fix the doc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

APPLY_FIXES and for PHP_PHPCSFIXER linter
3 participants