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

Allow linters to report warnings #4476

Open
bdovaz opened this issue Jan 10, 2025 · 6 comments · May be fixed by #4556
Open

Allow linters to report warnings #4476

bdovaz opened this issue Jan 10, 2025 · 6 comments · May be fixed by #4556
Labels
enhancement New feature or request

Comments

@bdovaz
Copy link
Collaborator

bdovaz commented Jan 10, 2025

Right now they only report bugs which is what appears in the reporters:

self.cli_lint_errors_count = None

def get_total_number_errors(self, stdout: str):

It would be nice to enable that at least warnings are also reported and evaluate if we want some severity level more. Warning severity level is standard, the rest depends on each linter because vale linter has “suggestion” level but there are others that will not have it or will be called differently.

@bdovaz bdovaz added the enhancement New feature or request label Jan 10, 2025
@bdovaz
Copy link
Collaborator Author

bdovaz commented Jan 10, 2025

@nvuillam @echoix what do you think?

@nvuillam
Copy link
Member

@bdovaz there is an old PR about that -> #1701 , but it has many impacts and has never been completed
But I would accept the PR of course :)

@bdovaz
Copy link
Collaborator Author

bdovaz commented Jan 21, 2025

@nvuillam I just brought the branch to this repository and merge main to bring it from past to present 😅

I will be working on it

@bdovaz bdovaz linked a pull request Jan 21, 2025 that will close this issue
4 tasks
@bdovaz
Copy link
Collaborator Author

bdovaz commented Jan 22, 2025

@nvuillam when analyzing this feature I have a doubt that probably has no solution but I raise it.... Many linters in their default output do not differentiate by “log level” (error vs warning) you only get issues with no detail about this. To know that level of detail some have a way to change to other output formats where they already detail in depth this information.

The problem is that if we change the default output of the linters we make that the megalinter logs artifacts do not output in a friendly format for the user that checks it...

cc @echoix

@nvuillam
Copy link
Member

@bdovaz I think we can do something like:

  • if cli_lint_warnings_count is set on the descriptor, count them
  • if not, the default number of warnings remain 0

I think that SARIF methods should also be updated to count warnings as they count errors

Here, we could the number of errors, undepending their level
https://github.com/oxsecurity/megalinter/blob/c58fb8fba775a2c2bcb4c817725e21ace5f829c0/megalinter/Linter.py#L1436C17-L1438C75

It needs to depending of what we want to count, filter with the num of items in result that have "level": "error" or "level": "warning"

@bdovaz
Copy link
Collaborator Author

bdovaz commented Jan 31, 2025

@nvuillam I have quite advanced the PR, take a look if you want at what I have so far, I think I don't have much left to fix.

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

Successfully merging a pull request may close this issue.

2 participants