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

error-level option does not work under analyze task #30

Closed
dancout opened this issue Mar 4, 2024 · 2 comments
Closed

error-level option does not work under analyze task #30

dancout opened this issue Mar 4, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@dancout
Copy link

dancout commented Mar 4, 2024

I am looking to specify error-level as error, implying that the analyzer should only fail in the event that an "error" is found. However, it is still failing to commit when a "warning" is found.

Here is my configuration in the pubspec.yaml file:

dart_pre_commit:
  analyze:
    error-level: error
    scan-mode: staged

I then made a change to a file that does have a linter warning present (the variable _authHandler is not used), and tried to commit.

Because this is just a warning, and not an error, I should be allowed to commit.
After running git commit -m "dummy commit", this is what my terminal shows:

git commit -m "dummy commit"
✅ Accepted file lib/services/org_chart_service.dart
🔎 Running analyze...
      warning - lib/services/org_chart_service.dart:13:21 - The value of the field '_authHandler' isn't used. Try removing the field, or using it. - unused_field
    1 issue(s) found.
❌ Completed analyze, found problems

So, it seems to me that the error-level config is not actually respecting the value that is being passed in, and always falls back on the default of "info".

@Skycoder42 Skycoder42 self-assigned this Mar 11, 2024
@Skycoder42 Skycoder42 added the bug Something isn't working label Mar 11, 2024
@Skycoder42
Copy link
Owner

I tried to reproduce the issue, and I think the problem lies in how the tool handles analyzer results. Currently, it ignores the exit code and simply checks if lints are present. This was done to enable scan-mode: staged, as the analyzer tool itself cannot be instructed to only scan parts of the project. However, as it seems, it will still print out warning, even if they are marked as non fatal.

This leaves me with 2 options: Remove the error-level completely or remove the scan-mode completely, as we can't do both. I personally would tend more to removing the scan-mode, as it is already artificial (because not natively supported by the dart analyzer) and has led to problems in the past (as changes in staged code might be error free, but could very well cause problems in other files).

I will notify you, once the updated version was released.

@Skycoder42
Copy link
Owner

Version 5.3.0 with the fixes has been published

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants