TabularEditor / BestPracticeRules

An official collection of standard Rules for use with Tabular Editor's Best Practice Analyzer.
121 stars 53 forks source link

[Rule Request] Per-Model Exceptions to BPA Rules #51

Open InsightABI opened 2 years ago

InsightABI commented 2 years ago

I'm not sure if this is a more of a BPA feature suggestion or a BPA Rule suggestion, but I think this could be done in the rule expression. We are utilizing Git for our CI/CD process and we invoke TE3 via CLI in Git to run the BPA to check before we allow a PR to be created or merged.

Because each model is different and will therefore have _it's own exceptions_ to the rules, can we put every existing rule's LINQ script inside of a "wrapper" that checks to see if the rule should apply to this particular model and then exit if it doesn't?

//Wrapper Pseodo-code IF Model.Name IN (array of model's to be ignored for this rule) EXIT ELSE run regular LINQ script END IF

otykier commented 2 years ago

Yes, if you remember to specify explicit names for your models, you can absolutely add that type of logic to each rule:

For example, if a rule should apply only to Model1, Model2 and Model3, use this:

(Model.Name = "Model1" or Model.Name = "Model2" or Model.Name = "Model3")
and
... // Regular LINQ expression

However, in my opinion, exceptions should be specified on the individual models, instead of on each rule. This can be done simply by loading a model in TE, then disable the rules you do not want to apply to that model. This information is then stored in an annotation on the model, so the next time the model is loaded, or when the BPA is executed through CLI, any rules specified as exceptions on the annotation will not be checked.