Skip to content

Lint: enforce naming standards for some layouts #19898

@david-allison

Description

@david-allison

Layouts:

  • Activity -> activity_
  • Fragment -> fragment_
  • View -> view_
  • Dialog -> dialog_

Task

This should be implemented in the following order:

  1. A lint rule should be created, for a constraint
  2. The lint breakages should be fixed in the same commit
  3. Repeat, for each of the 4 categories.

The implementation of the lint rules is the main complexity, I suspect that this should be partially implemented as an initial PR, and improved in a follow up PR

The easiest method of determining whether a layout is associated with an activity or Fragment is when it's passed into the constructor (see: vbpd)

class CardTemplateBrowserAppearanceEditor : AnkiActivity(R.layout.card_browser_appearance) {

This will handle a subset of activities and Fragments. Not all activities pass the layout into the constructor.

The more correct method is to use the name of the Binding class:

private val binding by viewBinding(CardBrowserAppearanceBinding::bind)

  • match the binding with the layout
  • determine the type of class that the binding is in

Prefer to be conservative: only raise a lint error if certain

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions