noop_primitive_operations
Noop プリミティブ操作。
詳細
#プリミティブ型に対する一部の操作は冪等であり、削除できます。
悪い例
dart
doubleValue.toDouble();
intValue.toInt();
intValue.round();
intValue.ceil();
intValue.floor();
intValue.truncate();
string.toString();
string = 'hello\n'
''
'world';
'string with ${x.toString()}';文字列の先頭または末尾にある空の文字列リテラルは、複数行にわたって文字列リテラルをフォーマットするために通常使用されるため、許可されることに注意してください。
dart
// OK
string = ''
'hello\n'
'world\n';
// OK
string = 'hello\n'
'world\n'
'';有効にする
#noop_primitive_operations ルールを有効にするには、analysis_options.yaml ファイルの linter > rules の下に noop_primitive_operations を追加します。
analysis_options.yaml
yaml
linter:
rules:
- noop_primitive_operations代わりに YAML マップ構文を使用してリンター ルールを構成している場合は、linter > rules の下に noop_primitive_operations: true を追加します。
analysis_options.yaml
yaml
linter:
rules:
noop_primitive_operations: true