How to prohibit bang operator in Dart Linter / Pull request

125

You could add that check if you integrate dart-code-metrics (package) to your pipeline. They have that specific rule available avoid-non-null-assertion , see it docs here.

You can install it as an extension to the regular analyzer, so everyone gets the rules enforced at development time. And its also available as a CLI for using in a pipeline.

Codemagic recently added it as an option for their builds if you're using that.

Share:
125
TSR
Author by

TSR

Updated on January 01, 2023

Comments

  • TSR
    TSR over 1 year

    Is it possible to fail a pull request pipeline if the developer has used the "Bang Operator" ?

    We are using dart linter already in our PR pipeline, is there such a rule to enforce the prohibition of the Bang Operator ?

    For example, this should not be allowed

    Deal deal = widget.deal!