A collection of custom Android/Kotlin lint checks we use in our Android and Kotlin code bases at Slack.

Overview

slack-lints

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

This repo is effectively read-only and does not publish artifacts to Maven Central. We develop these in the open though to knowledge share with the community.

As such, our issue tracker is closed and we don't normally accept external PRs, but we welcome your questions in the discussions section of the project!

We may later open source some of these lints. If you're interested in this, feel free to raise in a discussions post or vote for existing suggestions.

Highlights

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.

And more!

  • JavaOnlyDetector - detects use of Java-only APIs from Kotlin. Based on the original unreleased implementation in uber/lint-checks.
  • DaggerKotlinIssuesDetector - detects some known issues when using Dagger in Kotlin code.
  • RetrofitUsageDetector - detects some common issues when using Retrofit.
  • ...and a plethora of others!

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.
Comments
  • SpanMarkPointMissingMaskDetector - Ensure that span flags are checked correctly

    SpanMarkPointMissingMaskDetector - Ensure that span flags are checked correctly

    Summary

    Ensure that span flags are checked correctly.

    Incorrect spanned.getSpanFlags(span) == Spanned.INCLUSIVE_INCLUSIVE

    Correct spanned.getSpanFlags(span) and Spanned.SPAN_POINT_MARK_MASK == Spanned.INCLUSIVE_INCLUSIVE

    Why Spans flags may have priority bits or other bits set.

    image

    Requirements (place an x in each [ ])

    The following point can be removed after setting up CI (such as Travis) with coverage reports (such as Codecov)

    • [x] I've written tests to cover the new code and functionality included in this PR.

    The following point can be removed after setting up a CLA reporting tool such as cla-assistant.io

    opened by slack-jallen 7
  • Import DenyListedApiDetector

    Import DenyListedApiDetector

    This adapts a DenyListedApiDetector that the folks at Cash App shared. Initially it uses (most) of their lints with some tweaks (rxjava 3 for instance). We can use this as a platform to add more of our own in the future too

    opened by ZacSweers 2
  • Bump lint version to 30.4.0-alpha03

    Bump lint version to 30.4.0-alpha03

    Summary

    Bump lint version to 30.4.0-alpha03

    Requirements (place an x in each [ ])

    The following point can be removed after setting up CI (such as Travis) with coverage reports (such as Codecov)

    • [x] I've written tests to cover the new code and functionality included in this PR.

    The following point can be removed after setting up a CLA reporting tool such as cla-assistant.io

    opened by seankim-android 1
  • Call out the deprecated call in the lint message when reporting

    Call out the deprecated call in the lint message when reporting

    Summary

    In order to better analyze our deprecated calls in lint reports, it would be helpful if reports identified the referenced deprecation. This PR prefixes the error message with the referenced deprecation when it is available.

    Requirements (place an x in each [ ])

    The following point can be removed after setting up CI (such as Travis) with coverage reports (such as Codecov)

    • [x] I've written tests to cover the new code and functionality included in this PR.

    The following point can be removed after setting up a CLA reporting tool such as cla-assistant.io

    opened by bryanstern 1
  • Hunvil and josh/span point mark

    Hunvil and josh/span point mark

    Summary

    Spans flags can have priority or other bits set. Ensure that Span flags are checked using currentFlag and Spanned.SPAN_POINT_MARK_MASK == desiredFlag rather than just currentFlag == desiredFlag

    Requirements (place an x in each [ ])

    The following point can be removed after setting up CI (such as Travis) with coverage reports (such as Codecov)

    • [x] I've written tests to cover the new code and functionality included in this PR.

    The following point can be removed after setting up a CLA reporting tool such as cla-assistant.io

    opened by slack-jallen 1
  • Modernize repo infra

    Modernize repo infra

    • JVM target 11
      • Required for latest lint
    • Update to latest lint
      • Requires baselining some new test modes for now
    • Prepare for maven central releases
    • Switch to ktfmt + new simpler license header
    • Align slack-lint naming with its artifact id - slack-lint-checks
    opened by ZacSweers 0
  • Fix non-transitive R class lints

    Fix non-transitive R class lints

    This updates MissingResourceImportAliasDetector to use the module's package name instead of the file's to avoid false positives for modules with custom namespaces. It also updates the fix name for FullyQualifiedResourceDetector.

    opened by saifc 0
  • Use StringOption for inclusive naming lint

    Use StringOption for inclusive naming lint

    I found a vague reference in the sample lint config on this doc page that took me down a path to finding there's a new options API in lint for configuring lint detectors via the standard lint xml config.

    This updates the inclusive naming linter to use that pattern, so now we would add this entry to our lint.xml to configure this instead. Much nicer 👍.

    <?xml version="1.0" encoding="UTF-8"?>
    <lint>
        <issue id="InclusiveNaming">
            <option name="block-list" value="fork,knife,spoon,spork"/>
        </issue>
    </lint>
    
    
    opened by ZacSweers 0
  • Add non-transitive R class lints

    Add non-transitive R class lints

    This adds 3 lint checks that enforce the rules around referencing resources in a non-transitive R class world:

    Best reviewed by commit.

    | MissingResourceImportAliasDetector | WrongResourceImportAliasDetector | FullyQualifiedResourceDetector | | ----------- | ----------- | ----------- | |

    opened by saifc 0
  • Implement DoNotExposeEitherNetInRepositoriesDetector

    Implement DoNotExposeEitherNetInRepositoriesDetector

    We don't want folks to expose these types directly in the repository layer, it creates awkward situations where the UI suddenly has to know what to do about network failures as a state.

    opened by ZacSweers 0
  • Update lint versions and target latest

    Update lint versions and target latest

    This updates our project to the latest lint APIs and also begins targeting building against latest. This should fix compatibility on newer studio versions + ease updates in the future by targeting latest (even while we still support lower versions).

    opened by ZacSweers 0
Releases(0.1.1)
  • 0.1.1(Nov 30, 2022)

    • Fix: Fallback to file package name in MissingResourceImportAliasDetector if project package name is null.

    What's Changed

    • Fallback to file package name by @saifc in https://github.com/slackhq/slack-lints/pull/32

    Full Changelog: https://github.com/slackhq/slack-lints/compare/0.1.0...0.1.1

    Source code(tar.gz)
    Source code(zip)
Owner
Slack
On a mission to make your working life simpler, more pleasant and more productive.
Slack
ADX provides extension functions and lint.

ADX: Android development extensions Overview ADX provides extension functions and lint. Installation ADX implementation "com.github.wada811.adx:adx:$v

wada811 2 Nov 7, 2022
A custom installer for our mod that installs recommended mods (and more in the future).

Wynntils Mod Installer Our custom installer which makes it easier to set up optional mods and in the future, resourcepack options, and more! Screensho

Wynntils Team 4 Nov 30, 2022
Link previews between JetBrains Space and Slack

slack-unfurls This is the application for providing link previews between Slack and Space in both directions. It provides link previews for Slack mess

JetBrains 5 Sep 8, 2022
Launchy - A custom launcher for our server that installs recommended mods

Launchy Our custom launcher which makes it easier to set up optional mods and in

Mine In Abyss 8 Dec 10, 2022
Slack app example for Heroku deployment, written in Kotlin, using Bolt framework.

slack-kotlin-heroku-example Slack app example for Heroku deployment, written in Kotlin, using Bolt framework. You need to configure your Slack app to

null 0 Dec 25, 2021
This is a simple app to help get or set your Slack status from the command line.

Slack Status This is a simple app to help get or set your Slack status from the command line. The app is a Spring Boot app written in Kotlin. It uses

Steven Noto 1 Oct 16, 2021
An android app that lists all planets in our solar system and brings some information about them.

SolarSystem This application was developed in Android Studio and uses Kotlin as programming language. In short, it is an app that lists all the planet

Dayon Oliveira 0 Nov 3, 2021
Covidapp - The COVID-19 crisis and social distancing had a significant impact on our lives

Covid App The COVID-19 crisis and social distancing had a significant impact on

Abhinav 1 Jan 10, 2022
Synapse Moderation Bot - A bot for managing and moderating our community Discord server

Synapse Moderation Bot A bot for managing and moderating our community Discord server. Note This bot is not public. While you can host it on your own,

Synapse Technologies, LLC 1 Jul 16, 2022
Civihelper-project - This is our first android project .

Civihelper-project Problem-- Time taking and cumbersome conventional way to submit your civil problems. Proposed soln--- A platform to provide the sub

Kunal Kumar 1 Jun 6, 2022
ToDo App is a kind of app that generally used to maintain our day-to-day tasks or list everything that we have to do

ToDo App is a kind of app that generally used to maintain our day-to-day tasks or list everything that we have to do, with the most important tasks at the top of the list, and the least important tasks at the bottom. It is helpful in planning our daily schedules.

Hamza Gamal 9 Oct 16, 2022
TMDbHub - Listing movies using the TMDb API. You can filter results, view details, and save them to a collection

TMDb Hub Listing movies using the TMDb API. You can filter results, view details

David Varga 4 Dec 30, 2021
An extensive collection of Kotlin Android Utils

An extensive collection of Kotlin Android Utils This library contains small helper functions used throughout almost all of my other projects. The goal

Allan Wang 207 Dec 23, 2022
Custom MediaPicker for Android. support targetSdk 30 & scoped storage. And use registerForActivityResult rather than onActivityResult.

MoongchiPicker What is MoongchiPicker? MoongchiPicker is custom media gallery base on Google's Material Design Bottom Sheets. You can fetch image or v

펫프렌즈 5 Nov 26, 2022
Collection of Small Android Projects

AndroidDemoProjects ActivityRecognition: Example of using Google Play Services to recognize a user's activity, such as running, walking, or riding a b

Paul Ruiz 601 Dec 9, 2022
Linuxcnc probescripts - Collection of scripts for several touch-probe routines

linuxcnc_probescripts Collection of scripts for several touch-probe routines. Al

Multifuchs UG (haftungsbeschränkt) 0 Jan 30, 2022
📱 Andriller - is software utility with a collection of forensic tools for smartphones

Andriller - is software utility with a collection of forensic tools for smartphones. It performs read-only, forensically sound, non-destructive acquisition from Android devices. It has features, such as powerful Lockscreen cracking for Pattern, PIN code, or Password; custom decoders for Apps data from Android (some Apple iOS & Windows) databases for decoding communications. Extraction and decoders produce reports in HTML and Excel formats.

Denis Sazonov 980 Dec 27, 2022
Mole Analysis Use Case for HMS ML Kit Custom Model

Mole Analysis Mole Analysis Use Case for HMS ML Kit Custom Model Introduction What is Melanoma? Melanoma is the most serious among skin cancers becaus

null 15 Aug 23, 2022
BuildConfiguration information for use in multi-module, or Kotlin Multiplatform common code

component-build-configuration A small library supporting Kotlin Multiplatform for utilizing BuildConfiguration details from common code and across mod

Matthew Nelson 2 Mar 6, 2022