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
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ linter:

join_return_with_assignment: false

prefer_function_declarations_over_variables: false

unnecessary_string_escapes: false
#prefer_const_constructors
manjotsidhu marked this conversation as resolved.
Show resolved Hide resolved

non_constant_identifier_names: false

Expand Down
2 changes: 1 addition & 1 deletion test/setup/test_data/mock_ib_raw_page_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Map<String, dynamic> mockIbRawPageData1 = {
'description': '',
'permalink': '/',
'content':
'<h1 class=\"fs-9\" id=\"interactive-book\">Interactive-Book</h1>\n\n<p class=\"fs-6 fw-300\">Learn Digital Logic Design easily.</p>\n\n<p>The Computer Logical Organization is basically the abstraction which is below the operating system and above the digital logic level.\nNow at this point, the important points are the functional units/subsystems that refer to some hardware which is made up of lower level building blocks.</p>\n\n<p>This interactive book gives a complete understanding on Computer Logical Organization starting from basic computer overview till the advanced level.\nThis book is aimed to provide the knowledge to the reader on how to analyze the combinational and sequential circuits and implement them. You can use the combinational circuit/sequential circuit/combination of both the circuits, as per the requirement.\nAfter completing this book, you will be able to implement the type of digital circuit, which is suitable for specific application.</p>\n\n<hr />\n\n<h2 id=\"audience\">Audience</h2>\n\n<p>This book is mainly prepared for the students who are interested in the concepts of digital circuits and Computer Logical Organization. Digital circuits contain a set of Logic gates and these can be operated with binary values, 0 and 1.</p>\n\n<h3 id=\"prerequisites\">Prerequisites</h3>\n<p>Before you start learning from this Book, I hope that you have some basic knowledge about computers and how they work.\nA basic idea regarding the initial concepts of Digital Electronics is enough to understand the topics covered in this tutorial.</p>\n',
'<h1 class="fs-9" id="interactive-book">Interactive-Book</h1>\n\n<p class="fs-6 fw-300">Learn Digital Logic Design easily.</p>\n\n<p>The Computer Logical Organization is basically the abstraction which is below the operating system and above the digital logic level.\nNow at this point, the important points are the functional units/subsystems that refer to some hardware which is made up of lower level building blocks.</p>\n\n<p>This interactive book gives a complete understanding on Computer Logical Organization starting from basic computer overview till the advanced level.\nThis book is aimed to provide the knowledge to the reader on how to analyze the combinational and sequential circuits and implement them. You can use the combinational circuit/sequential circuit/combination of both the circuits, as per the requirement.\nAfter completing this book, you will be able to implement the type of digital circuit, which is suitable for specific application.</p>\n\n<hr />\n\n<h2 id="audience">Audience</h2>\n\n<p>This book is mainly prepared for the students who are interested in the concepts of digital circuits and Computer Logical Organization. Digital circuits contain a set of Logic gates and these can be operated with binary values, 0 and 1.</p>\n\n<h3 id="prerequisites">Prerequisites</h3>\n<p>Before you start learning from this Book, I hope that you have some basic knowledge about computers and how they work.\nA basic idea regarding the initial concepts of Digital Electronics is enough to understand the topics covered in this tutorial.</p>\n',
'dir': '/',
'url': '/',
'raw_content':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!

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

Expand Down
1 change: 1 addition & 0 deletions test/ui_tests/authentication/login_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ void main() {
await _pumpLoginView(tester);
await tester.pumpAndSettle();

// ignore: prefer_function_declarations_over_variables
var _loginImagePredicate =
(Widget widget) => widget is Image && widget.height == 300;

Expand Down
3 changes: 3 additions & 0 deletions test/ui_tests/authentication/signup_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void main() {
await _pumpSignupView(tester);
await tester.pumpAndSettle();

// ignore: prefer_function_declarations_over_variables
var _signupImagePredicate =
(Widget widget) => widget is Image && widget.height == 300;

Expand All @@ -63,8 +64,10 @@ void main() {
await _pumpSignupView(tester);
await tester.pumpAndSettle();

// ignore: prefer_function_declarations_over_variables
var _nameFieldPredicate =
(Widget widget) => widget is CVTextField && widget.label == 'Name';
// ignore: prefer_function_declarations_over_variables
var _emailFieldPredicate =
(Widget widget) => widget is CVTextField && widget.label == 'Email';

Expand Down