rokucommunity / bslint

A linter for BrightScript and BrighterScript.
MIT License
27 stars 14 forks source link

No rule for default values being set on init #87

Open charlie-abbott-deltatre opened 1 year ago

charlie-abbott-deltatre commented 1 year ago

There is currently no rule for catching redundant default values being set on init, so node.visible = true or node.translation = [0, 0] or within the XML <Rectangle visible="true" />

TwitchBronBron commented 1 year ago

In XML files, <Rectangle visible="true" /> this. could be a good rule and fairly easy to implement other than maintaining the large list of default values somewhere. But I think it might be incredibly difficult to detect these in brs/bs code. Consider this code:

sub init()
    m.top.visible = false
    if getRegistryValue("something") = true
        m.top.visibile = true
    end if
end sub

What should we do in that situation? Should it be flagged?

charlie-abbott-deltatre commented 1 year ago

Agree, this should fairly easy with XML, except for the work of defining/ maintaining the default values list per node type.

For brs/bs code there are potentially a lot of edge cases.