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(lints): unnecessary_string_escapes and prefer_function_declarations_over_variables rules #160

Merged
merged 7 commits into from
Oct 15, 2021

Conversation

Neha62-lit
Copy link
Contributor

Refer #149

Fix lint rules:

  • unnecessary_string_escapes
  • prefer_function_declarations_over_variables

@Neha62-lit
Copy link
Contributor Author

@manjotsidhu, Review this PR!

analysis_options.yaml Outdated Show resolved Hide resolved
@@ -42,6 +42,7 @@ void main() {
await _pumpForgotPasswordView(tester);
await tester.pumpAndSettle();

// ignore: prefer_function_declarations_over_variables
var _forgotPasswordImagePredicate =
Copy link
Member

@manjotsidhu manjotsidhu Oct 14, 2021

Choose a reason for hiding this comment

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

Ignoring the rule might not be the best thing to do here. The rule says if you want to make functions then prefer proper declarations instead of creating variables. More info: https://dart-lang.github.io/linter/lints/prefer_function_declarations_over_variables.html

In our case we can simply avoid creating the variable for function since we just have 1 usage of that variable and instead we will simply use the function implementation where we need it.

Example,
From :

 var _forgotPasswordImagePredicate =
  (Widget widget) => widget is Image && widget.height == 300;

expect(find.byWidgetPredicate(_forgotPasswordImagePredicate),
          findsOneWidget);

To:

expect(find.byWidgetPredicate((Widget widget) => widget is Image && widget.height == 300),
          findsOneWidget);

(needs formatting)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay,I Will do that.
Thank you!

@coveralls
Copy link

coveralls commented Oct 14, 2021

Pull Request Test Coverage Report for Build 1342827371

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 73.555%

Totals Coverage Status
Change from base Build 1342332513: 0.0%
Covered Lines: 3855
Relevant Lines: 5241

💛 - Coveralls

Copy link
Member

@manjotsidhu manjotsidhu left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@manjotsidhu manjotsidhu merged commit fb4df78 into CircuitVerse:master Oct 15, 2021
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