Skip to content

Ignore unnecessary_string_interpolations in messages_XX.dart files #73

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

Closed
bambinoua opened this issue Jun 29, 2021 · 4 comments
Closed

Comments

@bambinoua
Copy link

bambinoua commented Jun 29, 2021

I have this code in translation file

static String m1(isNew, table, message) => "${Intl.select(isNew, {
            'true':
                'Could not insert record into \'${table}\' table. ${message}',
            'false':
                'Could not update record into \'${table}\' table. ${message}',
          })}";

And my analysis_options.yaml contains this unnecessary_string_interpolations: true. So I have a warnig about unnecessary string interpolation. Is it possible to ignore this in messages files or remove redundant string interpolation from Intl.select

@bambinoua bambinoua changed the title Add unnecessary_string_interpolations: false in to Add unnecessary_string_interpolations: false into messages_XX.dart file Jun 29, 2021
@bambinoua bambinoua changed the title Add unnecessary_string_interpolations: false into messages_XX.dart file Ignore unnecessary_string_interpolations in messages_XX.dart files Jun 29, 2021
@lzoran
Copy link

lzoran commented Jun 30, 2021

Hi @bambinoua,

Thanks for reporting this!

The analysis_options.yaml file offers the option to exclude certain files and directories from analysis with the exclude section. Unfortunately, this does not work at the moment (issue).

I think this is more linter than a generated code issue. If you agree, I suggest leaving this open so we can monitor the need for this. In case of high demand, maybe we could add one more ignore rule within generated files.

@bambinoua
Copy link
Author

bambinoua commented Jul 1, 2021

Yes. My suggestion is just add the additional rule to generated files:

// Ignore issues from commonly used lints in this file.
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
// ignore_for_file:unnecessary_string_interpolations                                    <--- something like this

@lzoran
Copy link

lzoran commented Jul 13, 2021

Hi @bambinoua,

I've noticed that the previously mentioned issue with the exclude section within the analysis_options.yaml file works fine now with the latest Flutter version (Flutter 2.2.3) and the latest IDE extensions for Flutter and Dart.

Does updating analyzer config work for you?

The analysis_options.ymal file:

include: package:pedantic/analysis_options.yaml

analyzer:
  exclude:
    - lib/generated/intl/*.dart

linter:
  rules:
    - unnecessary_string_interpolations

@lzoran
Copy link

lzoran commented Nov 12, 2021

I'm closing this issue as the latest version of the Flutter Intl extension (1.17.0) generates code that should not complain for the unnecessary_string_interpolations lint rule.
In case you still see warnings after update to the latest version, please feel free to open a new issue.

@lzoran lzoran closed this as completed Nov 12, 2021
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

No branches or pull requests

2 participants