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) : non_constant_identifier_names #195

Closed
wants to merge 5 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 @@ -8,6 +8,4 @@ linter:
# Util classes
avoid_classes_with_only_static_members: false

non_constant_identifier_names: false

constant_identifier_names: false
4 changes: 2 additions & 2 deletions lib/services/database_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ enum DatabaseBox {
IB,
}

List<TypeAdapter> DatabaseAdapters = <TypeAdapter>[
List<TypeAdapter> databaseAdapters = <TypeAdapter>[
IbRawPageDataAdapter(),
];

Expand Down Expand Up @@ -37,7 +37,7 @@ class DatabaseServiceImpl implements DatabaseService {
}

// Register Adapters for Hive
for (var adapter in DatabaseAdapters) {
for (var adapter in databaseAdapters) {
Hive.registerAdapter(adapter);
}
}
Expand Down
10 changes: 5 additions & 5 deletions lib/services/ib_engine_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,19 @@ class IbEngineServiceImpl implements IbEngineService {
var toc = <IbTocItem>[];

for (var li in element.children) {
var eff_index = num ? index.toString() : String.fromCharCode(index);
var effIndex = num ? index.toString() : String.fromCharCode(index);
if (li.getElementsByTagName('ol').isNotEmpty) {
toc.add(
IbTocItem(
leading: '$eff_index.',
leading: '$effIndex.',
content: li.firstChild!.text!,
items: _parseToc(li.children[1], num: !num),
),
);
} else {
toc.add(
IbTocItem(
leading: '$eff_index.',
leading: '$effIndex.',
content: li.text,
),
);
Expand All @@ -191,7 +191,7 @@ class IbEngineServiceImpl implements IbEngineService {
var toc = <IbTocItem>[];

for (var li in element.children) {
var eff_index = num ? index.toString() : String.fromCharCode(index);
var effIndex = num ? index.toString() : String.fromCharCode(index);
var sublist = <IbTocItem>[];

for (var node in li.nodes) {
Expand All @@ -206,7 +206,7 @@ class IbEngineServiceImpl implements IbEngineService {

toc.add(
IbTocItem(
leading: '$eff_index.',
leading: '$effIndex.',
content: root ? li.nodes[0].text!.trim() : li.text.trim(),
items: sublist.isNotEmpty ? sublist : null,
),
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/views/about/about_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class _AboutViewState extends State<AboutView> {
}

Widget _buildContributorsList() {
switch (_model.stateFor(_model.FETCH_CONTRIBUTORS)) {
switch (_model.stateFor(_model.fetchCONTRIBUTORS)) {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So you mean to say these changes be reverted back and the lint for non_constant_identifier_names be kept false?

Copy link
Member

Choose a reason for hiding this comment

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

Check if you can avoid renaming the variables while supporting the rule.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not quite sure what you meant here😅. Do I have to revert the changes? Or add ignore statements at a few places?

Copy link
Member

Choose a reason for hiding this comment

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

We want to keep using UPPER_CASE for the current variables we have and while supporting non_constant_identifier_names.

You need make UPPER_CASE variables as const and keep them in UPPER_CASE. In this way the rule will not be causing issue since we made it a constant.

case ViewState.Success:
var _contributorsAvatars = <Widget>[];
for (var contributor in _model.cvContributors) {
Expand All @@ -76,7 +76,7 @@ class _AboutViewState extends State<AboutView> {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 32),
child: Text(
_model.errorMessageFor(_model.FETCH_CONTRIBUTORS),
_model.errorMessageFor(_model.fetchCONTRIBUTORS),
textAlign: TextAlign.center,
),
);
Expand Down
18 changes: 9 additions & 9 deletions lib/ui/views/authentication/components/auth_options_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,38 @@ class _AuthOptionsViewState extends State<AuthOptionsView> {
Future<void> onGoogleAuthPressed() async {
await _model.googleAuth(isSignUp: widget.isSignUp);

if (_model.isSuccess(_model.GOOGLE_OAUTH)) {
if (_model.isSuccess(_model.googleOAUTH)) {
await Get.offAllNamed(CVLandingView.id);
} else if (_model.isError(_model.GOOGLE_OAUTH)) {
} else if (_model.isError(_model.googleOAUTH)) {
SnackBarUtils.showDark(
'Google Authentication Error',
_model.errorMessageFor(_model.GOOGLE_OAUTH),
_model.errorMessageFor(_model.googleOAUTH),
);
}
}

Future<void> onFacebookAuthPressed() async {
await _model.facebookAuth(isSignUp: widget.isSignUp);

if (_model.isSuccess(_model.FB_OAUTH)) {
if (_model.isSuccess(_model.fbOAUTH)) {
await Get.offAllNamed(CVLandingView.id);
} else if (_model.isError(_model.FB_OAUTH)) {
} else if (_model.isError(_model.fbOAUTH)) {
SnackBarUtils.showDark(
'Facebook Authentication Error',
_model.errorMessageFor(_model.FB_OAUTH),
_model.errorMessageFor(_model.fbOAUTH),
);
}
}

Future<void> onGithubAuthPressed() async {
await _model.githubAuth(isSignUp: widget.isSignUp);

if (_model.isSuccess(_model.GITHUB_OAUTH)) {
if (_model.isSuccess(_model.githubOAUTH)) {
await Get.offAllNamed(CVLandingView.id);
} else if (_model.isError(_model.GITHUB_OAUTH)) {
} else if (_model.isError(_model.githubOAUTH)) {
SnackBarUtils.showDark(
'GitHub Authentication Error',
_model.errorMessageFor(_model.GITHUB_OAUTH),
_model.errorMessageFor(_model.githubOAUTH),
);
}
}
Expand Down
10 changes: 5 additions & 5 deletions lib/ui/views/authentication/login_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class _LoginViewState extends State<LoginView> {
padding: const EdgeInsets.symmetric(horizontal: 16),
width: double.infinity,
child: CVPrimaryButton(
title: _model.isBusy(_model.LOGIN) ? 'Authenticating..' : 'LOGIN',
title: _model.isBusy(_model.logIN) ? 'Authenticating..' : 'LOGIN',
onPressed: _validateAndSubmit,
),
);
Expand Down Expand Up @@ -120,10 +120,10 @@ class _LoginViewState extends State<LoginView> {

Future<void> _validateAndSubmit() async {
if (Validators.validateAndSaveForm(_formKey) &&
!_model.isBusy(_model.LOGIN)) {
!_model.isBusy(_model.logIN)) {
FocusScope.of(context).requestFocus(FocusNode());
await _model.login(_email, _password);
if (_model.isSuccess(_model.LOGIN)) {
if (_model.isSuccess(_model.logIN)) {
// show login successful snackbar..
SnackBarUtils.showDark(
'Login Successful',
Expand All @@ -132,11 +132,11 @@ class _LoginViewState extends State<LoginView> {
// move to home view on successful login..
await Future.delayed(const Duration(seconds: 1));
await Get.offAllNamed(CVLandingView.id);
} else if (_model.isError(_model.LOGIN)) {
} else if (_model.isError(_model.logIN)) {
// show failure snackbar..
SnackBarUtils.showDark(
'Error',
_model.errorMessageFor(_model.LOGIN),
_model.errorMessageFor(_model.logIN),
);
_formKey.currentState?.reset();
}
Expand Down
12 changes: 6 additions & 6 deletions lib/ui/views/authentication/signup_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class _SignupViewState extends State<SignupView> {
padding: const EdgeInsets.symmetric(horizontal: 16),
width: double.infinity,
child: CVPrimaryButton(
title: _signUpModel.isBusy(_signUpModel.SIGNUP)
title: _signUpModel.isBusy(_signUpModel.signUP)
? 'Authenticating..'
: 'REGISTER',
onPressed: _validateAndSubmit,
Expand Down Expand Up @@ -130,15 +130,15 @@ class _SignupViewState extends State<SignupView> {

Future<void> _validateAndSubmit() async {
if (Validators.validateAndSaveForm(_formKey) &&
!_signUpModel.isBusy(_signUpModel.SIGNUP)) {
!_signUpModel.isBusy(_signUpModel.signUP)) {
FocusScope.of(context).requestFocus(FocusNode());

await _signUpModel.signup(_name, _email, _password);

if (_signUpModel.isSuccess(_signUpModel.SIGNUP)) {
if (_signUpModel.isSuccess(_signUpModel.signUP)) {
// show signup successful snackbar..
SnackBarUtils.showDark(
'Signup Successful',
'signup Successful',
'Welcome to CircuitVerse!',
);

Expand All @@ -147,11 +147,11 @@ class _SignupViewState extends State<SignupView> {
const Duration(seconds: 1),
);
await Get.offAllNamed(CVLandingView.id);
} else if (_signUpModel.isError(_signUpModel.SIGNUP)) {
} else if (_signUpModel.isError(_signUpModel.signUP)) {
// show failure snackbar..
SnackBarUtils.showDark(
'Error',
_signUpModel.errorMessageFor(_signUpModel.SIGNUP),
_signUpModel.errorMessageFor(_signUpModel.signUP),
);
_formKey.currentState?.reset();
}
Expand Down
6 changes: 3 additions & 3 deletions lib/ui/views/groups/add_assignment_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class _AddAssignmentViewState extends State<AddAssignmentView> {

_dialogService.popDialog();

if (_model.isSuccess(_model.ADD_ASSIGNMENT)) {
if (_model.isSuccess(_model.addASSIGNMENT)) {
await Future.delayed(const Duration(seconds: 1));

// returns the added assignment..
Expand All @@ -244,11 +244,11 @@ class _AddAssignmentViewState extends State<AddAssignmentView> {
'Assignment Added',
'New assignment was successfully added.',
);
} else if (_model.isError(_model.ADD_ASSIGNMENT)) {
} else if (_model.isError(_model.addASSIGNMENT)) {
// Show failure snackbar
SnackBarUtils.showDark(
'Error',
_model.errorMessageFor(_model.ADD_ASSIGNMENT),
_model.errorMessageFor(_model.addASSIGNMENT),
);
_formKey.currentState?.reset();
}
Expand Down
20 changes: 10 additions & 10 deletions lib/ui/views/groups/assignment_details_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,15 @@ class _AssignmentDetailsViewState extends State<AssignmentDetailsView> {

_dialogService.popDialog();

if (_model.isSuccess(_model.ADD_GRADE)) {
if (_model.isSuccess(_model.addGRADE)) {
SnackBarUtils.showDark(
'Project Graded Successfully',
'You have graded the project.',
);
} else if (_model.isError(_model.ADD_GRADE)) {
} else if (_model.isError(_model.addGRADE)) {
SnackBarUtils.showDark(
'Error',
_model.errorMessageFor(_model.ADD_GRADE),
_model.errorMessageFor(_model.addGRADE),
);
}
}
Expand All @@ -287,15 +287,15 @@ class _AssignmentDetailsViewState extends State<AssignmentDetailsView> {

_dialogService.popDialog();

if (_model.isSuccess(_model.UPDATE_GRADE)) {
if (_model.isSuccess(_model.updateGRADE)) {
SnackBarUtils.showDark(
'Grade updated Successfully',
'Grade has been updated successfully.',
);
} else if (_model.isError(_model.UPDATE_GRADE)) {
} else if (_model.isError(_model.updateGRADE)) {
SnackBarUtils.showDark(
'Error',
_model.errorMessageFor(_model.UPDATE_GRADE),
_model.errorMessageFor(_model.updateGRADE),
);
}
}
Expand All @@ -314,17 +314,17 @@ class _AssignmentDetailsViewState extends State<AssignmentDetailsView> {

_dialogService.popDialog();

if (_model.isSuccess(_model.DELETE_GRADE)) {
if (_model.isSuccess(_model.deleteGRADE)) {
SnackBarUtils.showDark(
'Grade Deleted',
'Grade has been removed successfully.',
);
_gradesController.clear();
_remarksController.clear();
} else if (_model.isError(_model.DELETE_GRADE)) {
} else if (_model.isError(_model.deleteGRADE)) {
SnackBarUtils.showDark(
'Error',
_model.errorMessageFor(_model.DELETE_GRADE),
_model.errorMessageFor(_model.deleteGRADE),
);
}
}
Expand Down Expand Up @@ -458,7 +458,7 @@ class _AssignmentDetailsViewState extends State<AssignmentDetailsView> {
json.decode(_attrs.restrictions).join(' , '),
),
const Divider(height: 32),
if (_model.isSuccess(_model.FETCH_ASSIGNMENT_DETAILS))
if (_model.isSuccess(_model.fetchASSIGNMENTDETAILS))
Column(
children: <Widget>[
_buildSubmissions(),
Expand Down
6 changes: 3 additions & 3 deletions lib/ui/views/groups/edit_group_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ class _EditGroupViewState extends State<EditGroupView> {

_dialogService.popDialog();

if (_model.isSuccess(_model.UPDATE_GROUP)) {
if (_model.isSuccess(_model.updateGROUP)) {
await Future.delayed(const Duration(seconds: 1));
Get.back(result: _model.updatedGroup);
SnackBarUtils.showDark(
'Group Updated',
'Group has been successfully updated.',
);
} else if (_model.isError(_model.UPDATE_GROUP)) {
} else if (_model.isError(_model.updateGROUP)) {
SnackBarUtils.showDark(
'Error',
_model.errorMessageFor(_model.UPDATE_GROUP),
_model.errorMessageFor(_model.updateGROUP),
);
}
}
Expand Down
Loading