https://github.com/kengotoda/errorprone-slf4j
An Error Prone plugin for SLF4J
https://github.com/kengotoda/errorprone-slf4j
error-prone slf4j static-analysis
Last synced: about 1 year ago
JSON representation
An Error Prone plugin for SLF4J
- Host: GitHub
- URL: https://github.com/kengotoda/errorprone-slf4j
- Owner: KengoTODA
- License: apache-2.0
- Created: 2018-06-28T14:12:11.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2025-04-25T17:11:00.000Z (about 1 year ago)
- Last Synced: 2025-04-25T18:27:31.023Z (about 1 year ago)
- Topics: error-prone, slf4j, static-analysis
- Language: Java
- Size: 815 KB
- Stars: 32
- Watchers: 3
- Forks: 4
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Find and fix misusage of SLF4J with Google Error Prone
This is a plugin for [Google Error Prone](http://errorprone.info/), that detects misusage of [SLF4J](https://www.slf4j.org/).
This provides almost same feature with [findbugs-slf4j](https://github.com/KengoTODA/findbugs-slf4j).
[](https://github.com/KengoTODA/errorprone-slf4j/actions/workflows/build.yml)
[](https://sonarcloud.io/dashboard?id=jp.skypencil.errorprone.slf4j%3Aerrorprone-slf4j)
[](https://maven-badges.herokuapp.com/maven-central/jp.skypencil.errorprone.slf4j/errorprone-slf4j)
[](https://github.com/semantic-release/semantic-release)
## Supported Bug Patterns
Current version supports following bug patterns:
* [Slf4jPlaceholderMismatch](https://github.com/KengoTODA/findbugs-slf4j#slf4j_place_holder_mismatch)
* [Slf4jFormatShouldBeConst](https://github.com/KengoTODA/findbugs-slf4j#slf4j_format_should_be_const)
* [Slf4jLoggerShouldBePrivate](https://github.com/KengoTODA/findbugs-slf4j#slf4j_logger_should_be_private)
* [Slf4jLoggerShouldBeFinal](https://github.com/KengoTODA/findbugs-slf4j#slf4j_logger_should_be_final)
* [Slf4jLoggerShouldBeNonStatic](https://github.com/KengoTODA/findbugs-slf4j#slf4j_logger_should_be_non_static)
* [Slf4jIllegalPassedClass](https://github.com/KengoTODA/findbugs-slf4j#slf4j_illegal_passed_class)
* [Slf4jSignOnlyFormat](https://github.com/KengoTODA/findbugs-slf4j#slf4j_sign_only_format)
* [Slf4jDoNotLogMessageOfExceptionExplicitly](https://github.com/KengoTODA/findbugs-slf4j#slf4j_manually_provided_message)
## Install
After [installation of Error Prone](https://errorprone.info/docs/installation), introduce errorprone-slf4j as plugin. Refer [official document](https://errorprone.info/docs/plugins#build-system-support) or following examples:
### Maven
`maven-compiler-plugin` supports `` from version 3.5. Use it in configuration of `maven-compiler-plugin` like below:
```xml
org.apache.maven.plugins
maven-compiler-plugin
...
jp.skypencil.errorprone.slf4j
errorprone-slf4j
0.1.20
```
### Gradle
From v4.6, [Gradle supports `annotationProcessor` configuration](https://docs.gradle.org/4.6/release-notes.html#convenient-declaration-of-annotation-processor-dependencies) so you can configure your project like below:
```groovy
dependencies {
annotationProcessor 'jp.skypencil.errorprone.slf4j:errorprone-slf4j:0.1.20'
}
```
with Kotlin DSL
```kotlin
dependencies {
errorprone("jp.skypencil.errorprone.slf4j:errorprone-slf4j:0.1.20")
}
```
If you want to disable some rules:
```kotlin
import net.ltgt.gradle.errorprone.errorprone
tasks.withType().configureEach {
options.errorprone {
disable("Slf4jLoggerShouldBeNonStatic")
}
}
```
## Copyright
Copyright 2012-2022 Kengo TODA
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.