Detekt: Extend VarCouldBeVal Rule to Include Class/Object Properties

Created on 13 Nov 2018  路  4Comments  路  Source: detekt/detekt

Expected Behavior of the rule



Currently, the VarCouldBeVal rule only reports on locally-scoped function variables. It would be nice if the rule could be extended to include private top-level class/object properties as well.

For example

class Test {
    private var viewModel = BaseViewModel() // Not re-assigned anywhere else in the class
    ...
}

should report a violation.

Context




Theses are valid errors that should be reported to fix unnecessary mutability.

feature help wanted rules

Most helpful comment

I'll actually go ahead and give this one a shot 馃憤

All 4 comments

I'll actually go ahead and give this one a shot 馃憤

@tylerbwong do you any update on this feature? Do you need assistance?

Hey @schalkms sorry for the late reply. I've actually haven't found the time to work on this lately so it'd probably be best to let someone else work on it 馃槥

@tylerbwong no worries.. thanks for the reply.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BraisGabin picture BraisGabin  路  3Comments

jcornaz picture jcornaz  路  3Comments

arturdryomov picture arturdryomov  路  4Comments

MyDogTom picture MyDogTom  路  3Comments

danikula picture danikula  路  4Comments