dart_custom_lint
dart_custom_lint copied to clipboard
Running in CI pipeline fails because plugin is loading
My custom linter works fine in the IDE and when run on the terminal with flutter pub run custom_lint.
But when I try to run flutter analyze in a CI pipeline to analyze my code for the default lints, I get this output and the command fails:
Analyzing my_app...
warning • The plugin is currently starting • pubspec.yaml:121:2 • custom_lint_plugin_loading
1 issue found. (ran in 101.0s)
I've tried adding another CI step before the flutter analyze step which executes the custom linter first. The flutter pub run custom_lint CI step works fine, but even after that step finished I still get the above error when running flutter analyze in subsequent CI step.
Is there a way to wait until the plugin has started? Or is there some workaround so I can use custom_lint in a CI pipeline?
+1 this and unfortunately the only option is to disable all this lib as it is linked to the dart analyzer (CI and IDE)
I think the if from packages/custom_lint/lib/src/analyzer_plugin/lints.dart should be totally deleted (message not very helpful anyway) :

Great lib BTW ;)
I'm currently using the following workaround on CI:
- run
flutter pub run custom_lint - run a script which removes
custom_lintfromanalysis_options.yaml - run
flutter analyze
Python script for editing analysis_options.yaml
import yaml
with open('analysis_options.yaml', 'r+') as file:
pubspec = yaml.safe_load(file)
file.seek(0)
file.truncate()
del pubspec["analyzer"]["plugins"]
yaml.safe_dump(pubspec, file)
This way, you can use both flutter pub run custom_lint as well as flutter analyze on CI without flutter analyze causing the custom_lint_plugin_loading error.
Nice workaround @Giuspepe.
I had the same issue here, and following your way I did the same in the shell script, which seems simpler, and independent of having python in the environment.
I will leave it here, hope to be useful to someone that is facing the same issue:
echo 'Removing custom lint from all analysis_options.yaml files...'
for yaml_file_path in $(find . -name 'analysis_options.yaml' -print); do
# When in an Apple environment, it only works with the additional ''.
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' '/- custom_lint/d' $yaml_file_path
else
sed -i '/- custom_lint/d' $yaml_file_path
fi
done
Credits also to @LuisMiguelMP.