Skip to content

Commit

Permalink
fix(lints): enable linter rules (#172)
Browse files Browse the repository at this point in the history
* rfrac: enable `always_put_required_named_parameters_first` rule

* rfrac: enable `join_return_with_assignment` linter
  • Loading branch information
aman-singh7 authored Nov 26, 2021
1 parent 051c308 commit fdd62be
Show file tree
Hide file tree
Showing 29 changed files with 66 additions and 114 deletions.
7 changes: 1 addition & 6 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@ analyzer:

linter:
rules:
# Use parameter order as in json response
always_put_required_named_parameters_first: false

# Util classes
avoid_classes_with_only_static_members: false

avoid_redundant_argument_values: false

join_return_with_assignment: false

non_constant_identifier_names: false
non_constant_identifier_names: false

constant_identifier_names: false
2 changes: 1 addition & 1 deletion lib/models/ib/ib_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ abstract class IbContent {
}

class IbTocItem extends IbContent {
IbTocItem({this.leading, @required String content, this.items})
IbTocItem({@required String content, this.leading, this.items})
: super(content: content);

final String leading;
Expand Down
6 changes: 2 additions & 4 deletions lib/services/API/assignments_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ class HttpAssignmentsApi implements AssignmentsApi {
uri,
headers: headers,
);
var assignments = Assignments.fromJson(jsonResponse);
return assignments;
return Assignments.fromJson(jsonResponse);
} on ForbiddenException {
throw Failure(Constants.UNAUTHORIZED);
} on NotFoundException {
Expand Down Expand Up @@ -107,8 +106,7 @@ class HttpAssignmentsApi implements AssignmentsApi {
headers: headers,
body: json,
);
var assignment = Assignment.fromJson(jsonResponse['data']);
return assignment;
return Assignment.fromJson(jsonResponse['data']);
} on BadRequestException {
throw Failure(Constants.INVALID_PARAMETERS);
} on ForbiddenException {
Expand Down
3 changes: 1 addition & 2 deletions lib/services/API/collaborators_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ class HttpCollaboratorsApi implements CollaboratorsApi {
uri,
headers: headers,
);
var collaborators = Collaborators.fromJson(jsonResponse);
return collaborators;
return Collaborators.fromJson(jsonResponse);
} on UnauthorizedException {
throw Failure(Constants.UNAUTHORIZED);
} on NotFoundException {
Expand Down
4 changes: 1 addition & 3 deletions lib/services/API/contributors_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class HttpContributorsApi implements ContributorsApi {

try {
var _jsonResponse = await ApiUtils.get(_url, headers: headers);
var _listOfContributors =
circuitVerseContributorsFromJson(jsonEncode(_jsonResponse));
return _listOfContributors;
return circuitVerseContributorsFromJson(jsonEncode(_jsonResponse));
} on FormatException {
throw Failure(Constants.BAD_RESPONSE_FORMAT);
} on Exception {
Expand Down
3 changes: 1 addition & 2 deletions lib/services/API/grades_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ class HttpGradesApi implements GradesApi {
headers: headers,
body: json,
);
var grade = Grade.fromJson(jsonResponse['data']);
return grade;
return Grade.fromJson(jsonResponse['data']);
} on ForbiddenException {
throw Failure(Constants.UNAUTHORIZED);
} on NotFoundException {
Expand Down
3 changes: 1 addition & 2 deletions lib/services/API/group_members_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ class HttpGroupMembersApi implements GroupMembersApi {
uri,
headers: headers,
);
var groupMembers = GroupMembers.fromJson(jsonResponse);
return groupMembers;
return GroupMembers.fromJson(jsonResponse);
} on UnauthorizedException {
throw Failure(Constants.UNAUTHORIZED);
} on NotFoundException {
Expand Down
15 changes: 5 additions & 10 deletions lib/services/API/groups_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ class HttpGroupsApi implements GroupsApi {
uri,
headers: headers,
);
var groups = Groups.fromJson(jsonResponse);
return groups;
return Groups.fromJson(jsonResponse);
} on UnauthorizedException {
throw Failure(Constants.UNAUTHORIZED);
} on Exception {
Expand All @@ -53,8 +52,7 @@ class HttpGroupsApi implements GroupsApi {
uri,
headers: headers,
);
var groups = Groups.fromJson(jsonResponse);
return groups;
return Groups.fromJson(jsonResponse);
} on UnauthorizedException {
throw Failure(Constants.UNAUTHORIZED);
} on Exception {
Expand All @@ -73,8 +71,7 @@ class HttpGroupsApi implements GroupsApi {
uri,
headers: headers,
);
var group = Group.fromJson(jsonResponse);
return group;
return Group.fromJson(jsonResponse);
} on UnauthorizedException {
throw Failure(Constants.UNAUTHENTICATED);
} on ForbiddenException {
Expand All @@ -99,8 +96,7 @@ class HttpGroupsApi implements GroupsApi {
headers: headers,
body: json,
);
var group = Group.fromJson(jsonResponse);
return group;
return Group.fromJson(jsonResponse);
} on UnauthorizedException {
throw Failure(Constants.UNAUTHENTICATED);
} on Exception {
Expand All @@ -121,8 +117,7 @@ class HttpGroupsApi implements GroupsApi {
headers: headers,
body: json,
);
var group = Group.fromJson(jsonResponse);
return group;
return Group.fromJson(jsonResponse);
} on UnauthorizedException {
throw Failure(Constants.UNAUTHENTICATED);
} on ForbiddenException {
Expand Down
21 changes: 7 additions & 14 deletions lib/services/API/projects_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ class HttpProjectsApi implements ProjectsApi {
uri,
headers: headers,
);
var projects = Projects.fromJson(jsonResponse);
return projects;
return Projects.fromJson(jsonResponse);
} on Exception {
throw Failure(Constants.GENERIC_FAILURE);
}
Expand All @@ -94,8 +93,7 @@ class HttpProjectsApi implements ProjectsApi {
uri,
headers: headers,
);
var projects = Projects.fromJson(jsonResponse);
return projects;
return Projects.fromJson(jsonResponse);
} on UnauthorizedException {
throw Failure(Constants.UNAUTHENTICATED);
} on NotFoundException {
Expand Down Expand Up @@ -123,8 +121,7 @@ class HttpProjectsApi implements ProjectsApi {
uri,
headers: headers,
);
var projects = Projects.fromJson(jsonResponse);
return projects;
return Projects.fromJson(jsonResponse);
} on UnauthorizedException {
throw Failure(Constants.UNAUTHENTICATED);
} on Exception {
Expand All @@ -150,8 +147,7 @@ class HttpProjectsApi implements ProjectsApi {
uri,
headers: headers,
);
var projects = Projects.fromJson(jsonResponse);
return projects;
return Projects.fromJson(jsonResponse);
} on UnauthorizedException {
throw Failure(Constants.UNAUTHENTICATED);
} on Exception {
Expand All @@ -170,8 +166,7 @@ class HttpProjectsApi implements ProjectsApi {
uri,
headers: headers,
);
var project = Project.fromJson(jsonResponse);
return project;
return Project.fromJson(jsonResponse);
} on UnauthorizedException {
throw Failure(Constants.UNAUTHENTICATED);
} on ForbiddenException {
Expand Down Expand Up @@ -207,8 +202,7 @@ class HttpProjectsApi implements ProjectsApi {
headers: headers,
body: json,
);
var project = Project.fromJson(jsonResponse['data']);
return project;
return Project.fromJson(jsonResponse['data']);
} on BadRequestException {
throw Failure(Constants.INVALID_PARAMETERS);
} on UnauthorizedException {
Expand Down Expand Up @@ -277,8 +271,7 @@ class HttpProjectsApi implements ProjectsApi {
uri,
headers: headers,
);
var project = Project.fromJson(jsonResponse['data']);
return project;
return Project.fromJson(jsonResponse['data']);
} on UnauthorizedException {
throw Failure(Constants.UNAUTHENTICATED);
} on NotFoundException {
Expand Down
18 changes: 6 additions & 12 deletions lib/services/API/users_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ class HttpUsersApi implements UsersApi {
headers: headers,
body: json,
);
String token = jsonResponse['token'];
return token;
return jsonResponse['token'];
} on ConflictException {
throw Failure(Constants.USER_AUTH_USER_ALREADY_EXISTS);
} on FormatException {
Expand All @@ -99,8 +98,7 @@ class HttpUsersApi implements UsersApi {
headers: headers,
body: json,
);
String token = jsonResponse['token'];
return token;
return jsonResponse['token'];
} on NotFoundException {
throw Failure(Constants.USER_AUTH_USER_NOT_FOUND);
} on FormatException {
Expand All @@ -125,8 +123,7 @@ class HttpUsersApi implements UsersApi {
headers: headers,
body: json,
);
String token = jsonResponse['token'];
return token;
return jsonResponse['token'];
} on ConflictException {
throw Failure(Constants.USER_AUTH_USER_ALREADY_EXISTS);
} on FormatException {
Expand All @@ -146,8 +143,7 @@ class HttpUsersApi implements UsersApi {
uri,
headers: headers,
);
var user = User.fromJson(jsonResponse);
return user;
return User.fromJson(jsonResponse);
} on FormatException {
throw Failure(Constants.BAD_RESPONSE_FORMAT);
} on NotFoundException {
Expand All @@ -167,8 +163,7 @@ class HttpUsersApi implements UsersApi {
uri,
headers: headers,
);
var user = User.fromJson(jsonResponse);
return user;
return User.fromJson(jsonResponse);
} on FormatException {
throw Failure(Constants.BAD_RESPONSE_FORMAT);
} on Exception {
Expand All @@ -194,8 +189,7 @@ class HttpUsersApi implements UsersApi {
headers: headers,
body: json,
);
var user = User.fromJson(jsonResponse);
return user;
return User.fromJson(jsonResponse);
} on FormatException {
throw Failure(Constants.BAD_RESPONSE_FORMAT);
} on Exception {
Expand Down
11 changes: 5 additions & 6 deletions lib/services/database_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ class DatabaseServiceImpl implements DatabaseService {
Future<bool> isExpired(String key) async {
var data = await getData<DateTime>(DatabaseBox.Metadata, key);

if (data == null ||
return data == null ||
data.isBefore(
DateTime.now().subtract(Duration(hours: _timeoutHours)))) {
return true;
}

return false;
DateTime.now().subtract(
Duration(hours: _timeoutHours),
),
);
}

@override
Expand Down
22 changes: 7 additions & 15 deletions lib/services/ib_engine_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ class IbEngineServiceImpl implements IbEngineService {
// Build Navigation
_chapters = _buildNav(_chapters);

_ibChapters = _chapters;
return _ibChapters;
return _ibChapters = _chapters;
}

/// Recursively parses list of table of contents
Expand Down Expand Up @@ -224,23 +223,17 @@ class IbEngineServiceImpl implements IbEngineService {
var document = parse(content);
var mdElement = document.getElementById('markdown-toc');

if (mdElement != null) {
return _parseToc(mdElement);
} else {
return [];
}
return mdElement != null ? _parseToc(mdElement) : [];
}

/// Fetches Chapter of Contents from HTML Content
List<IbTocItem> _getChapterOfContents(String content) {
var document = parse(content);
var mdElement = document.getElementById('chapter-contents-toc');

if (mdElement != null) {
return _parseChapterContents(mdElement, root: true);
} else {
return [];
}
return mdElement != null
? _parseChapterContents(mdElement, root: true)
: [];
}

/// Fetches "Rich" Page Content
Expand Down Expand Up @@ -286,10 +279,9 @@ class IbEngineServiceImpl implements IbEngineService {
var result = '$js\n$html';

// Replace local URLs with absolute
result = result.replaceAll(RegExp(r'(\.\.(\/\.\.)?)?(?<!org)\/assets'),
return result = result.replaceAll(
RegExp(r'(\.\.(\/\.\.)?)?(?<!org)\/assets'),
'${EnvironmentConfig.IB_BASE_URL}/assets');

return result;
}

@override
Expand Down
4 changes: 1 addition & 3 deletions lib/services/local_storage_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ class LocalStorageService {
static const String AUTH_TYPE = 'auth_type';

static Future<LocalStorageService> getInstance() async {
_instance ??= LocalStorageService();

_preferences ??= await SharedPreferences.getInstance();

return _instance;
return _instance ??= LocalStorageService();
}

dynamic _getFromDisk(String key) {
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/components/cv_drawer_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:mobile_app/cv_theme.dart';

class CVDrawerTile extends StatelessWidget {
const CVDrawerTile({Key key, @required this.title, this.iconData, this.color})
const CVDrawerTile({@required this.title, this.iconData, this.color, Key key})
: super(key: key);

final String title;
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/components/cv_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:mobile_app/cv_theme.dart';

class CVHeader extends StatelessWidget {
const CVHeader(
{Key key, @required this.title, this.subtitle, this.description})
{@required this.title, this.subtitle, this.description, Key key})
: super(key: key);

final String title;
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/components/cv_html_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import 'package:mobile_app/cv_theme.dart';

class CVHtmlEditor extends StatelessWidget {
const CVHtmlEditor({
Key key,
@required this.editorKey,
this.hasAttachment = true,
this.height = 300,
Key key,
}) : super(key: key);

final GlobalKey<FlutterSummernoteState> editorKey;
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/components/cv_outline_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import 'package:mobile_app/cv_theme.dart';

class CVOutlineButton extends StatelessWidget {
const CVOutlineButton({
Key key,
@required this.title,
this.onPressed,
this.isBodyText = false,
this.isPrimaryDark = false,
Key key,
}) : super(key: key);

final String title;
Expand Down
Loading

0 comments on commit fdd62be

Please sign in to comment.