TabularEditor / BestPracticeRules

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

"Remove unused columns" rule error #19

Closed DaniilMaslyuk closed 6 years ago

DaniilMaslyuk commented 6 years ago

The "Remove unused columns" rule returns the following error: No property or field 'Dependants' exists in type 'DataColumn'

image I tried this on both 1200 and 1400 compatibility levels, and I still get the same error.

Other rules do not have such issues.

Am I doing something incorrectly?

otykier commented 6 years ago

Thanks for reporting this. There was a breaking change in the underlying data model of Tabular Editor 2.7, in which I forgot to update the definition of this rule. Could you please try to change the expression of the rule to:

(IsHidden or Table.IsHidden)
and ReferencedBy.Count = 0 
and (not UsedInRelationships.Any())
and (not UsedInSortBy.Any())
and (not UsedInHierarchies.Any())
and (not Table.RowLevelSecurity.Any(
    it <> null and 
    it.IndexOf("[" + current.Name + "]", "OrdinalIgnoreCase") >= 0
))
and (not Model.Roles.Any(RowLevelSecurity.Any(
    it <> null and 
    (
        it.IndexOf(current.Table.Name + "[" + current.Name + "]", "OrdinalIgnoreCase") >= 0 or
        it.IndexOf("'" + current.Table.Name + "'[" + current.Name + "]", "OrdinalIgnoreCase") >= 0
    )
)))

Not only does this support the new data model in 2.7, but it also does some additional checks to make sure that a column isn't being used in RLS.

I've updated the source for this rule, and by the way, I've also added a PERF_UNUSED_MEASURES rule. Let me know if you have any further issues!