Skip to content

Support YAML list format for analysis_options includes, and update tests accordingly#158

Open
leventkantaroglu wants to merge 3 commits intoWorkiva:masterfrom
leventkantaroglu:update-getAnalysisOptionsIncludePackage
Open

Support YAML list format for analysis_options includes, and update tests accordingly#158
leventkantaroglu wants to merge 3 commits intoWorkiva:masterfrom
leventkantaroglu:update-getAnalysisOptionsIncludePackage

Conversation

@leventkantaroglu
Copy link

The getAnalysisOptionsIncludePackage method previously only supported single string includes in analysis_options.yaml files, but modern Dart/Flutter projects often use YAML list format for includes to reference multiple configuration packages. This enhancement adds support for the list format commonly used in projects like:

include:
  - package:flutter_lints/flutter.yaml
  - package:pedantic/analysis_options.1.8.0.yaml

This change improves the dependency validator's ability to detect analysis option packages that should be included in dependency validation, regardless of the YAML format used.

Copy link

@alanknight-wk alanknight-wk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!
A couple of very small style nits.
The checker also wants the files formatted, and an entry in the CHANGELOG.

// For more info on analysis options:
// https://dart.dev/guides/language/analysis-options#the-analysis-options-file
if (optionsIncludePackage != null) optionsIncludePackage,
if (optionsIncludePackage != null && optionsIncludePackage.isNotEmpty)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: why is this check necessary? Wouldn't ...[] do nothing?

final dynamic include = analysisOptions['include'];
if (include == null) return null;

final Set<String> packageNames = <String>{};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We generally follow this rule https://dart.dev/effective-dart/design#dont-redundantly-type-annotate-initialized-local-variables so the explicit declaration isn't necessary.


final String? include = analysisOptions['include'];
if (include == null || !include.startsWith('package:')) return null;
final dynamic include = analysisOptions['include'];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Slight preference for Object? over dynamic.

@kongo2002
Copy link

Hi, what's the status on this issue? We recently ran into the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants