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

feat: Add more lint rules #1703

Merged
merged 7 commits into from
Jun 6, 2022
Merged

feat: Add more lint rules #1703

merged 7 commits into from
Jun 6, 2022

Conversation

spydon
Copy link
Member

@spydon spydon commented Jun 6, 2022

Description

Adds some more lint rules and fixes the issues those rules pointed out.

Checklist

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, docs: etc).
  • I have read the Contributor Guide and followed the process outlined for submitting PRs.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples.

Breaking Change

  • No, this is not a breaking change.

Related Issues

@spydon spydon enabled auto-merge (squash) June 6, 2022 16:35
Copy link
Contributor

@st-pasha st-pasha left a comment

Choose a reason for hiding this comment

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

I just tried adding a single rule

linter:
  rules:
    - prefer_asserts_with_message

Into the packages/flame/analysis_options.yaml file, and sure enough it reports 28 violations of that rule. Which means that even though this PR adds the same rule, the test system somehow failed to run the proper analysis with that rule.

I haven't tried with any other rule, but I suspect there are 100 or so violations still hiding in the larger repo, and we just need to figure out why they are hiding...

@st-pasha
Copy link
Contributor

st-pasha commented Jun 6, 2022

Also, the prefer_asserts_with_messages is the only rule that I don't like very much. There are plenty of cases where asserts should be without messages because those messages don't add any valuable information. For example, in

assert(_parent != null, 'parent cannot be null');

the message is purely tautological and I don't see any way to actually improve it. At the same time, assert messages frequently cause the line to become longer than 80 chars, forcing a single-line assert into a more bloated 4+ lines of code.

@spydon
Copy link
Member Author

spydon commented Jun 6, 2022

I just tried adding a single rule

linter:
  rules:
    - prefer_asserts_with_message

Into the packages/flame/analysis_options.yaml file, and sure enough it reports 28 violations of that rule. Which means that even though this PR adds the same rule, the test system somehow failed to run the proper analysis with that rule.

I haven't tried with any other rule, but I suspect there are 100 or so violations still hiding in the larger repo, and we just need to figure out why they are hiding...

I think I broke it by forgetting to add rules: on the Flame pubspec, fixing now.

@spydon
Copy link
Member Author

spydon commented Jun 6, 2022

Also, the prefer_asserts_with_messages is the only rule that I don't like very much. There are plenty of cases where asserts should be without messages because those messages don't add any valuable information. For example, in

assert(_parent != null, 'parent cannot be null');

the message is purely tautological and I don't see any way to actually improve it. At the same time, assert messages frequently cause the line to become longer than 80 chars, forcing a single-line assert into a more bloated 4+ lines of code.

Removing that rule.

@spydon spydon merged commit 49252f8 into main Jun 6, 2022
@spydon spydon deleted the spydon.new-lint-rules branch June 6, 2022 19:23
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.

3 participants