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

Please fix: Missing types, consts, final, #43

Closed
talamaska opened this issue Apr 27, 2020 · 1 comment · Fixed by #44
Closed

Please fix: Missing types, consts, final, #43

talamaska opened this issue Apr 27, 2020 · 1 comment · Fixed by #44

Comments

@talamaska
Copy link
Contributor

talamaska commented Apr 27, 2020

Thee are multiple inconsistencies with the pedantic analysis options
The most critical one is implicit-dynamic: false, in the load method, because I have to disable it in order to be able to build with the generated translations.
Here key and value don't have types, they should be at least dynamic, but as the translations should be key/value pairs of strings for a valid json I think you should put types here and also avoid "as" syntax.

_translations = jsonMap
        .map<String, String>((key, value) => MapEntry(key, value as String));

Next TranslationKeys

class TranslationKeys {
  static final String pleaseAuthenticate = 'please_authenticate';

  static final String viewReadme = 'view_readme';
}

The rule that I have is underlining those as
Prefer const over final for declarations.dart(prefer_const_declarations)

Next Usage of var

var jsonStr =
        await rootBundle.loadString('i18n/${locale.languageCode}.json');

the rule I have here that is broken is
Prefer final for variable declarations if they are not reassigned.dart(prefer_final_locals)

Next Map jsonMap = json.decode(jsonStr);
Prefer final for variable declarations if they are not reassigned.dart(prefer_final_locals)

Next String get viewReadme => this.resolve(TranslationKeys.viewReadme);
Don't access members with this unless avoiding shadowing.dart(unnecessary_this)

Next const ['bg', 'en'].contains(locale.languageCode); and var translation = Translation();

Specify type annotations.dart(always_specify_types)

I'm sure if this is intended, f the generator actually can make those fixed at all. but generally those are good suggestions to fix, even if you are not using pedantic or w/e analysis options.

@AdamLonger
Copy link
Contributor

Merged. Closing issue

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 a pull request may close this issue.

2 participants