Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I ignore files with dartanalyzer?

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"
like image 554
Pacane Avatar asked Feb 04 '23 17:02

Pacane


2 Answers

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]

like image 71
Evandro Junior Avatar answered Feb 06 '23 09:02

Evandro Junior


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.

like image 30
Muldec Avatar answered Feb 06 '23 07:02

Muldec