21

I want to ignore all files ending with .g.dart, .inject.dart, .inject.summary in bin/ lib/ and test/

What is the syntax to ignore files dartanalyzer? I tried adding this section to my analysis_options.yaml file:

analyzer:
  exclude:
    - lib/**.g.dart

to my analysis_options.yaml and when I run dartanalyzer on my project it doesn't take that in consideration. I also tried using dartanalyzer --options analysis_options.yaml to make sure it'd use these options without luck.

The only syntax that I found would work with dartanalyzer cli tool was:

analyzer:
  exclude:
    - **/*.g.dart

but IntelliJ says it's an error (Undefined alias.)

if I use this syntax:

analyzer:
  exclude:
    - lib/**.g.dart
    - lib/**.inject.dart
    - lib/**.inject.summary
    - test/**.g.dart
    - test/**.inject.dart

The analyzer embedded in IntelliJ filters correctly those files, but the dartanalyzer cli tool doesn't.

Is there any way that works both with IntelliJ and the dartanalyzer CLI tool?

Note:

I'm using

❯ dart --version
Dart VM version: 2.4.0 (Wed Jun 19 11:53:45 2019 +0200) on "linux_x64"
Pacane
  • 20,273
  • 18
  • 60
  • 97
  • 3
    Well there's [an issue](https://github.com/dart-lang/sdk/issues/25551) on dartanalyzer about that. It's a known problem for a long time. – Muldec Jul 19 '19 at 15:08
  • 1
    @Muldec points to the right issue you might want to promote that to an answer. This isn't solvable today. https://github.com/dart-lang/sdk/issues/34069 is another issue discussing at a higher level the desire for different analysis in generated code. – Nate Bosch Jul 19 '19 at 17:04

2 Answers2

30

As you can see in the docs (https://dart.dev/guides/language/analysis-options) the correct syntax of excluding files from analyzer is:

include: package:very_good_analysis/analysis_options.yaml
analyzer:
  exclude: [build/**, lib/**.freezed.dart, lib/**.g.dart]

Evandro Junior
  • 391
  • 3
  • 4
  • you could emphasize the difference from the example the OP gave because it might not be obvious at first glance. – Rtzoor Nov 05 '22 at 10:48
4

Well there's an issue on dartanalyzer about that. It's a known problem for a long time and won't be solved anytime soon.

Muldec
  • 4,641
  • 1
  • 25
  • 44