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): constant_identifier_names #192

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ linter:
avoid_classes_with_only_static_members: false

non_constant_identifier_names: false

constant_identifier_names: false
16 changes: 8 additions & 8 deletions lib/config/environment_config.dart
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
class EnvironmentConfig {
static const String CV_API_BASE_URL = String.fromEnvironment(
static const String cvAPIBASEURL = String.fromEnvironment(
'CV_API_BASE_URL',
defaultValue: 'https://circuitverse.org/api/v1',
);

static const String IB_API_BASE_URL = String.fromEnvironment(
static const String ibAPIBASEURL = String.fromEnvironment(
'IB_API_BASE_URL',
defaultValue: 'https://learn.circuitverse.org/_api/pages',
);

static const String IB_BASE_URL = String.fromEnvironment(
static const String ibBASEURL = String.fromEnvironment(
'IB_BASE_URL',
defaultValue: 'https://learn.circuitverse.org',
);

// GITHUB OAUTH ENV VARIABLES
static const String GITHUB_OAUTH_CLIENT_ID = String.fromEnvironment(
static const String githubOAUTHCLIENTID = String.fromEnvironment(
'GITHUB_OAUTH_CLIENT_ID',
);
static const String GITHUB_OAUTH_CLIENT_SECRET = String.fromEnvironment(
static const String githubOAUTHCLIENTSECRET = String.fromEnvironment(
'GITHUB_OAUTH_CLIENT_SECRET',
);
static const String GITHUB_OAUTH_REDIRECT_URI = String.fromEnvironment(
static const String githubOAUTHREDIRECTURI = String.fromEnvironment(
'GITHUB_OAUTH_REDIRECT_URI',
defaultValue: 'circuitverse://auth/callback/github',
);

// FB OAUTH ENV VARIABLES
static const String FB_APP_NAME = String.fromEnvironment('FB_APP_NAME');
static const String FB_APP_ID = String.fromEnvironment('FB_APP_ID');
static const String fbAPPNAME = String.fromEnvironment('FB_APP_NAME');
static const String fbAPPID = String.fromEnvironment('FB_APP_ID');
}
39 changes: 20 additions & 19 deletions lib/constants.dart
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
class Constants {
/// USER CONSTANTS
static const String USER_AUTH_WRONG_CREDENTIALS =
static const String userAUTHWRONGCREDENTIALS =
'Invalid credentials, please check';
static const String USER_AUTH_USER_NOT_FOUND =
'User not found, try signing up';
static const String USER_AUTH_USER_ALREADY_EXISTS =
static const String userAUTHUSERNOTFOUND = 'User not found, try signing up';
static const String userAUTHUSERALREADYEXISTS =
'User already exists, try login';
static const String USER_NOT_AUTHORIZED_TO_FETCH_USER =
static const String userNOTAUTHORIZEDTOFETCHUSER =
'You are not authorized to fetch this user';
static const String USER_NOT_FOUND = 'User not found';
static const String userNOTFOUND = 'User not found';

/// PROJECT CONSTANTS
static const String PROJECT_NOT_FOUND = 'No project was found';
static const String PROJECT_FORK_CONFLICT = 'Cannot fork your own project';
static const String projectNOTFOUND = 'No project was found';
static const String projectFORKCONFLICT = 'Cannot fork your own project';

/// COLLABORATOR CONSTANTS
static const String COLLABORATOR_NOT_FOUND =
static const String collaboratorNOTFOUND =
'The requested collaborator does not exists';

/// GROUP RELATED CONSTANTS
static const String GROUP_NOT_FOUND = 'The requested group does not exists';
static const String groupNOTFOUND = 'The requested group does not exists';

/// GROUP MEMBERS CONSTANTS
static const String GROUP_MEMBER_NOT_FOUND =
static const String groupMEMBERNOTFOUND =
'The requested group member does not exists';

/// ASSIGNMENTS CONSTANTS
static const String ASSIGNMENT_ALREADY_OPENED =
static const String assignmentALREADYOPENED =
'The assignment is already opened';
static const String ASSIGNMENT_NOT_FOUND =
static const String assignmentNOTFOUND =
'The requested assignment does not exists';

/// GRADE CONSTANTS
static const String GRADE_NOT_FOUND = 'Grade not found';
static const String gradeNOTFOUND = 'Grade not found';

/// GENERIC FAILURE CONSTANTS
static const String BAD_RESPONSE_FORMAT = 'Bad response format';
static const String INVALID_PARAMETERS = 'Invalid parameters, retry!';
static const String GENERIC_FAILURE =
static const String badRESPONSEFORMAT = 'Bad response format';
static const String invalidPARAMETERS = 'Invalid parameters, retry!';
static const String genericFAILURE =
'Something wrong occurred! please try again';
static const String NO_INTERNET_CONNECTION = 'No internet connection';
static const String HTTP_EXCEPTION = 'Unable to fetch response';
static const String noINTERNETCONNECTION = 'No internet connection';
static const String httpEXCEPTION = 'Unable to fetch response';
// ignore: constant_identifier_names
static const String UNAUTHENTICATED =
'Unauthenticated to perform this action';
// ignore: constant_identifier_names
static const String UNAUTHORIZED = 'Unauthorized to perform this action';
}
10 changes: 5 additions & 5 deletions lib/enums/auth_type.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:mobile_app/utils/enum_values.dart';

enum AuthType { EMAIL, FACEBOOK, GOOGLE, GITHUB }
enum AuthType { email, facebook, google, github }

final authTypeValues = EnumValues({
'email': AuthType.EMAIL,
'facebook': AuthType.FACEBOOK,
'google': AuthType.GOOGLE,
'github': AuthType.GITHUB,
'email': AuthType.email,
'facebook': AuthType.facebook,
'google': AuthType.google,
'github': AuthType.github,
});
2 changes: 2 additions & 0 deletions lib/enums/view_state.dart
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
// ignore_for_file: constant_identifier_names

enum ViewState { Idle, Busy, Error, Success }
6 changes: 3 additions & 3 deletions lib/models/cv_contributors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ class CircuitVerseContributor {
int contributions;
}

enum Type { USER, BOT }
enum Type { user, bot }

final typeValues = EnumValues({
'Bot': Type.BOT,
'User': Type.USER,
'Bot': Type.bot,
'User': Type.user,
});
48 changes: 24 additions & 24 deletions lib/services/API/assignments_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class HttpAssignmentsApi implements AssignmentsApi {
@override
Future<Assignments> fetchAssignments(String groupId, {int page = 1}) async {
var endpoint = '/groups/$groupId/assignments?page[number]=$page';
var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint;
var uri = EnvironmentConfig.cvAPIBASEURL + endpoint;

try {
ApiUtils.addTokenToHeaders(headers);
Expand All @@ -52,16 +52,16 @@ class HttpAssignmentsApi implements AssignmentsApi {
} on ForbiddenException {
throw Failure(Constants.UNAUTHORIZED);
} on NotFoundException {
throw Failure(Constants.GROUP_NOT_FOUND);
throw Failure(Constants.groupNOTFOUND);
} on Exception {
throw Failure(Constants.GENERIC_FAILURE);
throw Failure(Constants.genericFAILURE);
}
}

@override
Future<Assignment> fetchAssignmentDetails(String assignmentId) async {
var endpoint = '/assignments/$assignmentId?include=grades,projects';
var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint;
var uri = EnvironmentConfig.cvAPIBASEURL + endpoint;

try {
ApiUtils.addTokenToHeaders(headers);
Expand All @@ -74,9 +74,9 @@ class HttpAssignmentsApi implements AssignmentsApi {
} on ForbiddenException {
throw Failure(Constants.UNAUTHORIZED);
} on NotFoundException {
throw Failure(Constants.ASSIGNMENT_NOT_FOUND);
throw Failure(Constants.assignmentNOTFOUND);
} on Exception {
throw Failure(Constants.GENERIC_FAILURE);
throw Failure(Constants.genericFAILURE);
}
}

Expand All @@ -90,7 +90,7 @@ class HttpAssignmentsApi implements AssignmentsApi {
String restrictions,
) async {
var endpoint = '/groups/$groupId/assignments';
var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint;
var uri = EnvironmentConfig.cvAPIBASEURL + endpoint;
var json = {
'name': name,
'deadline': deadline,
Expand All @@ -108,13 +108,13 @@ class HttpAssignmentsApi implements AssignmentsApi {
);
return Assignment.fromJson(jsonResponse['data']);
} on BadRequestException {
throw Failure(Constants.INVALID_PARAMETERS);
throw Failure(Constants.invalidPARAMETERS);
} on ForbiddenException {
throw Failure(Constants.UNAUTHORIZED);
} on NotFoundException {
throw Failure(Constants.GROUP_NOT_FOUND);
throw Failure(Constants.groupNOTFOUND);
} on Exception {
throw Failure(Constants.GENERIC_FAILURE);
throw Failure(Constants.genericFAILURE);
}
}

Expand All @@ -127,7 +127,7 @@ class HttpAssignmentsApi implements AssignmentsApi {
String restrictions,
) async {
var endpoint = '/assignments/$assignmentId';
var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint;
var uri = EnvironmentConfig.cvAPIBASEURL + endpoint;
var json = {
'name': name,
'deadline': deadline,
Expand All @@ -145,20 +145,20 @@ class HttpAssignmentsApi implements AssignmentsApi {
var assignment = Assignment.fromJson(jsonResponse['data']);
return assignment;
} on BadRequestException {
throw Failure(Constants.INVALID_PARAMETERS);
throw Failure(Constants.invalidPARAMETERS);
} on ForbiddenException {
throw Failure(Constants.UNAUTHORIZED);
} on NotFoundException {
throw Failure(Constants.ASSIGNMENT_NOT_FOUND);
throw Failure(Constants.assignmentNOTFOUND);
} on Exception {
throw Failure(Constants.GENERIC_FAILURE);
throw Failure(Constants.genericFAILURE);
}
}

@override
Future<bool> deleteAssignment(String assignmentId) async {
var endpoint = '/assignments/$assignmentId';
var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint;
var uri = EnvironmentConfig.cvAPIBASEURL + endpoint;

try {
ApiUtils.addTokenToHeaders(headers);
Expand All @@ -170,16 +170,16 @@ class HttpAssignmentsApi implements AssignmentsApi {
} on ForbiddenException {
throw Failure(Constants.UNAUTHORIZED);
} on NotFoundException {
throw Failure(Constants.ASSIGNMENT_NOT_FOUND);
throw Failure(Constants.assignmentNOTFOUND);
} on Exception {
throw Failure(Constants.GENERIC_FAILURE);
throw Failure(Constants.genericFAILURE);
}
}

@override
Future<String> reopenAssignment(String assignmentId) async {
var endpoint = '/assignments/$assignmentId/reopen';
var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint;
var uri = EnvironmentConfig.cvAPIBASEURL + endpoint;

try {
ApiUtils.addTokenToHeaders(headers);
Expand All @@ -188,18 +188,18 @@ class HttpAssignmentsApi implements AssignmentsApi {
} on ForbiddenException {
throw Failure(Constants.UNAUTHORIZED);
} on NotFoundException {
throw Failure(Constants.ASSIGNMENT_NOT_FOUND);
throw Failure(Constants.assignmentNOTFOUND);
} on ConflictException {
throw Failure(Constants.ASSIGNMENT_ALREADY_OPENED);
throw Failure(Constants.assignmentALREADYOPENED);
} on Exception {
throw Failure(Constants.GENERIC_FAILURE);
throw Failure(Constants.genericFAILURE);
}
}

@override
Future<String> startAssignment(String assignmentId) async {
var endpoint = '/assignments/$assignmentId/start';
var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint;
var uri = EnvironmentConfig.cvAPIBASEURL + endpoint;

try {
ApiUtils.addTokenToHeaders(headers);
Expand All @@ -208,9 +208,9 @@ class HttpAssignmentsApi implements AssignmentsApi {
} on ForbiddenException {
throw Failure(Constants.UNAUTHORIZED);
} on NotFoundException {
throw Failure(Constants.ASSIGNMENT_NOT_FOUND);
throw Failure(Constants.assignmentNOTFOUND);
} on Exception {
throw Failure(Constants.GENERIC_FAILURE);
throw Failure(Constants.genericFAILURE);
}
}
}
18 changes: 9 additions & 9 deletions lib/services/API/collaborators_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class HttpCollaboratorsApi implements CollaboratorsApi {
@override
Future<Collaborators> fetchProjectCollaborators(String projectId) async {
var endpoint = '/projects/$projectId/collaborators';
var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint;
var uri = EnvironmentConfig.cvAPIBASEURL + endpoint;

try {
ApiUtils.addTokenToHeaders(headers);
Expand All @@ -38,9 +38,9 @@ class HttpCollaboratorsApi implements CollaboratorsApi {
} on UnauthorizedException {
throw Failure(Constants.UNAUTHORIZED);
} on NotFoundException {
throw Failure(Constants.PROJECT_NOT_FOUND);
throw Failure(Constants.projectNOTFOUND);
} on Exception {
throw Failure(Constants.GENERIC_FAILURE);
throw Failure(Constants.genericFAILURE);
}
}

Expand All @@ -50,7 +50,7 @@ class HttpCollaboratorsApi implements CollaboratorsApi {
String listOfMails,
) async {
var endpoint = '/projects/$projectId/collaborators';
var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint;
var uri = EnvironmentConfig.cvAPIBASEURL + endpoint;
var json = {'emails': listOfMails};

try {
Expand All @@ -65,9 +65,9 @@ class HttpCollaboratorsApi implements CollaboratorsApi {
} on UnauthorizedException {
throw Failure(Constants.UNAUTHORIZED);
} on NotFoundException {
throw Failure(Constants.PROJECT_NOT_FOUND);
throw Failure(Constants.projectNOTFOUND);
} on Exception {
throw Failure(Constants.GENERIC_FAILURE);
throw Failure(Constants.genericFAILURE);
}
}

Expand All @@ -77,7 +77,7 @@ class HttpCollaboratorsApi implements CollaboratorsApi {
String collaboratorId,
) async {
var endpoint = '/projects/$projectId/collaborators/$collaboratorId';
var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint;
var uri = EnvironmentConfig.cvAPIBASEURL + endpoint;

try {
ApiUtils.addTokenToHeaders(headers);
Expand All @@ -89,9 +89,9 @@ class HttpCollaboratorsApi implements CollaboratorsApi {
} on UnauthorizedException {
throw Failure(Constants.UNAUTHORIZED);
} on NotFoundException {
throw Failure(Constants.COLLABORATOR_NOT_FOUND);
throw Failure(Constants.collaboratorNOTFOUND);
} on Exception {
throw Failure(Constants.GENERIC_FAILURE);
throw Failure(Constants.genericFAILURE);
}
}
}
4 changes: 2 additions & 2 deletions lib/services/API/contributors_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class HttpContributorsApi implements ContributorsApi {
var _jsonResponse = await ApiUtils.get(_url, headers: headers);
return circuitVerseContributorsFromJson(jsonEncode(_jsonResponse));
} on FormatException {
throw Failure(Constants.BAD_RESPONSE_FORMAT);
throw Failure(Constants.badRESPONSEFORMAT);
} on Exception {
throw Failure(Constants.GENERIC_FAILURE);
throw Failure(Constants.genericFAILURE);
}
}
}
Loading