slackhq / slack-lints

A collection of custom Android/Kotlin lint checks we use in our Android and Kotlin code bases at Slack.
Apache License 2.0
218 stars 10 forks source link
android android-lint kotlin lint static-analysis

slack-lints

This repository contains a collection of custom Android/Kotlin lint checks we use in our Android and Kotlin code bases at Slack.

While we do publish artifacts to Maven Central, some of the lints checks may only really be relevant to Slack's codebase. We develop these in the open to knowledge-share with the community.

Installation

Add the dependency to the lintChecks configuration. Note for non-android projects, you must apply the com.android.lint Gradle plugin to use this.

Maven Central

dependencies {
  lintChecks("com.slack.lint:slack-lint-checks:<version>")
}

Overview

Do Not Mock

The slack.lint.mocking package contains several detectors and utilities for detecting mocking of types that should not be mocked. This is similar to ErrorProne's DoNotMockChecker and acts as an enforcement layer to APIs and classes annotated with @DoNotMock. This also detects common types that should never be mocked, such as Kotlin data classes or AutoValue classes.

Inclusivity

In order to write more inclusive code, we have an InclusiveNamingChecker tool to check for a configurable list of non-inclusive names.

Moshi

MoshiUsageDetector contains a wealth of checks for common programmer errors when writing classes for use with Moshi and MoshiX.

Misc

License

Copyright 2021 Slack Technologies, LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.