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

Support error severity screening option #129

Merged

Conversation

yamarkz
Copy link
Contributor

@yamarkz yamarkz commented Mar 22, 2023

Custom Lint is a cool tool and makes my project better.
A few additional features would make the operation easier. This PR will add an option to screen Error Severity.

I implemented this issue on my own since it was a separate issue from #101 .

Any thoughts or policies? If not, I would be happy to have a positive consideration for the merge based on this PR.
My project is going to have a constructive Custom Lint maintenance once this change is in place.

@docs-page
Copy link

docs-page bot commented Mar 22, 2023

To view this pull requests documentation preview, visit the following URL:

docs.custom-lint.dev/~129

Documentation is deployed and generated using docs.page.

@vercel
Copy link

vercel bot commented Mar 22, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
custom-lint-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 29, 2023 7:34am

@CLAassistant
Copy link

CLAassistant commented Mar 22, 2023

CLA assistant check
All committers have signed the CLA.

@yamarkz
Copy link
Contributor Author

yamarkz commented Mar 22, 2023

@rrousselGit please review

@yamarkz
Copy link
Contributor Author

yamarkz commented Apr 8, 2023

@rrousselGit

What do you think? If you do not accept the changes, please close it.

' ${_relativeFilePath(error.location.file, workingDirectory)}:${error.location.startLine}:${error.location.startColumn}'
' • ${error.message} • ${error.code}',
);
hasErrors |= error.severity == AnalysisErrorSeverity.ERROR;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't use |=. This is the | operator, not ||.
So the == would be executed even though it's unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed commit 36140d7


if (hasErrors) {
exitCode = 1;
return;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we're going to use "return", there's no need for the for loop above to iterate over all errors. It probably should stop as soon as one unignored error/warning/info is found

Copy link
Contributor Author

@yamarkz yamarkz Jun 18, 2023

Choose a reason for hiding this comment

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

fixed commit 36140d7

I didn't take enough considerations for code efficiency

@@ -72,7 +72,7 @@ void main() {
test_app2/lib/main2.dart:1:6 • Hello world • hello_world
''',
);
expect(process.exitCode, 1);
expect(process.exitCode, 0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

That's not right. If a lint if emitted, it should emit 1 not 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm considering the following configuration.

  1. ErrorSeverity.info => Optional error (default exit code 0)
  2. ErrorSeverity.warning => Default error, but optionally skippable (default exit code 1)
  3. ErrorSeverity.error => Always error (default exit code 1)

This is consistent with the terminology used in Dart analyze.

modifying the parameter definition here. So it will be changed to return an exit code of 0.

Could you please share your thoughts on the design for this ErrorSeverity? I would appreciate hearing your considerations and insights.

I have contemplated aligning it with the fundamental design of Dart analyzer.
However, I am unsure if it aligns with the overall philosophy of this package.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would prefer basing custom_lint on flutter analyze rather than dart analyze.

With flutter analyze, infos lead to an exitCode 1 too, and you do flutter analyze --no-fatal-infos

)
]);

final helloWordPluginSource = createPluginSource([
TestLintRule(
code: 'hello_world',
message: 'Hello world',
errorSeverity: 'ErrorSeverity.WARNING',
Copy link
Collaborator

Choose a reason for hiding this comment

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

This impacts existing tests.

You should instead make a separate variable with the warning flag instead of reusing something already used by different tests but with the info status.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

before considering setting up another test, I would like to confirm this discussion first.

@@ -258,27 +334,27 @@ class _Lint extends DartLintRule {
) {
final line2 = resolver.lineInfo.getOffsetOfLine(1);
reporter.reportErrorForOffset(
const LintCode(name: 'x2', problemMessage: 'x2'),
const LintCode(name: 'x2', problemMessage: 'x2', errorSeverity: ErrorSeverity.WARNING),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why these changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason is the same as here.

@@ -37,6 +38,7 @@ class TestLintRule {
final String onVariable;
final String ruleMembers;
final List<TestLintFix> fixes;
final String errorSeverity;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't use a String for this. Either make an enum or use the official ErrorSeverity object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed commit 8fffd8d

@rrousselGit
Copy link
Collaborator

Hello! Sorry for the slow review. The notification was lost in the sea of notifications I receive :(

I had another pass at this. It's looking mostly good! But there are some relatively minor issues. Mind fixing them?

@yamarkz
Copy link
Contributor Author

yamarkz commented Apr 19, 2023

@rrousselGit

Thank you for maintaining the package, No problem.

I will follow your path.

@rrousselGit rrousselGit self-assigned this May 24, 2023
@rrousselGit
Copy link
Collaborator

👋 Do you still plan to work on this? :)

@yamarkz
Copy link
Contributor Author

yamarkz commented Jun 9, 2023

@rrousselGit

Oops I may have misunderstood. I expected to be presented with a completely different alternative.
Can I take ownership of PR? if yes. Can I proceed with the revision according to the review comments?

Our development team is still waiting for this change.

@rrousselGit
Copy link
Collaborator

👋

I don't quite understand what the confusion is. Do you mind explaining?
But anyway, this PR is waiting for you to fix the various points I raised previously. Once they are fixed and I think all changes look good, this can be merged

Co-authored-by: Remi Rousselet <darky12s@gmail.com>
await cli.entrypoint(['--no-fatal-infos']);

expect(err, emitsDone);
expect(exitCode, 0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you test that out still logs the infos/warnings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed commit 882b9bb

Copy link
Collaborator

@rrousselGit rrousselGit left a comment

Choose a reason for hiding this comment

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

The code is looking good!

If you update the tests to check that out still includes the logs, I'm happy to merge this asap and deploy it :)

@rrousselGit
Copy link
Collaborator

Great thanks! I'll wait for the CI to complete and merge this

@rrousselGit rrousselGit merged commit f9c988d into invertase:main Aug 29, 2023
oskar-zeinomahmalat-sonarsource pushed a commit to oskar-zeinomahmalat-sonarsource/dart_custom_lint that referenced this pull request Dec 3, 2024
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.

4 participants