• Stars
    star
    255
  • Rank 153,788 (Top 4 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Gradle plugin to launch IDEA inspections

JetBrains incubator project TeamCity (simple build status) GitHub license

IDEA inspection plugin

This plugin is intended to run IDEA inspections during Gradle build.

Current status: beta version 0.3.3 is available till 30 April 2021.

IMPORTANT: deprecation announcement

After EAP start for Qodana and the planned sunset of Bintray, we decided not to support inspection plugin anymore. Beginning from 1 May 2021, inspection plugin will not be more accessible at bintray and therefore will be unusable from this date. At this point we recommend migration to Qodana, as this tool has much better support and architectural stability.

This GitHub project will be archived soon.

Examples

  • Regular Gradle project -- see sample subdirectory here
  • Another regular Gradle project -- here
  • Android project -- see another sample

Usage

  • Add maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' } to your buildscript repositories (temporary location)
  • Add classpath 'org.jetbrains.intellij.plugins:inspection-plugin:0.3.2' to your buildscript dependencies
  • Apply plugin 'org.jetbrains.intellij.inspections' to your gradle module

This adds one inspection plugin task per source root, normally its name is inspectionsMain for main root and inspectionsTest for test root respectively. Also plugin adds reformat task per source root. They have the same usage (reformatMain, refeomatTest and etc.)

Also you should specify IDEA version to use and (optionally) kotlin plugin version to use, e.g.

inspections {
    idea.version "ideaIC:2019.1.4"
    plugins.kotlin.version "1.3.72" 
}

In this example inspections will be taken from IDEA CE version 2019.1.4. Plugin works at least with IDEA CE versions 2017.1, 2017.2, 2017.2.x, 2017.3, 2017.3.x, 2018.1, 2018.1.x, 2018.2, 2018.2.x. IDEA CE 2018.3, 2018.3.x, 2019.1, 2019.1.x are supported in plugins 0.3.0+ only. If you have multi-platform project, it's recommended to use IDEA CE 2018.2 or later. Kotlin plugin versions from 1.2.21 to 1.2.71 are supported directly (required version for your IDE is chosen and downloaded automatically), otherwise you will have to specify download URL (see below, plugins.kotlin.location). Kotlin plugin versions 1.3.0 to 1.3.72 are supported directly in plugins 0.3.0+ only.

Plugins 0.2.2 and earlier support only so-called local inspections (most Kotlin inspections fall into this category). Global inspections (e.g. most Android Lint and part of Java inspections) are supported only in 0.3.0+.

There are three ways to specify inspections for code analysis:

Inherit from IDEA

inspections {
    inheritFromIdea = true
}

In this case inspection configuration will be read from file .idea/inspectionProfiles/Project_Default.xml. If profileName is not given, Project_Default.xml will be used by default.

Manual inspections list

inspections {
    error('org.jetbrains.kotlin.idea.inspections.DataClassPrivateConstructorInspection')
    error('org.jetbrains.kotlin.idea.inspections.UseExpressionBodyInspection')
    warning('org.jetbrains.kotlin.idea.inspections.RedundantVisibilityModifierInspection')
    warning('org.jetbrains.kotlin.idea.inspections.AddVarianceModifierInspection')
    info('org.jetbrains.java.generate.inspection.ClassHasNoToStringMethodInspection')
}

In this case inspections from manually defined list will be in use.

Plugins 0.3.0+ allows shorter format (class name only without Inspection suffix):

inspections {
    error('DataClassPrivateConstructor')
    error('UseExpressionBody')
    warning('RedundantVisibilityModifier')
    warning('AddVarianceModifier')
    info('ClassHasNoToStringMethod')
}

or this way (via displayable inspection names):

inspections {
    error("Private data class constructor is exposed via the 'copy' method")
    error("Expression body syntax is preferable here")
    warning("Redundant visibility modifier")
    warning("Type parameter can have 'in' or 'out' variance")
    info("Class does not override 'toString()' method")
}

Mixing definition

inspections {
    inheritFromIdea = true
    error('org.jetbrains.kotlin.idea.inspections.DataClassPrivateConstructorInspection')
    error('org.jetbrains.kotlin.idea.inspections.UseExpressionBodyInspection')
    warning('org.jetbrains.kotlin.idea.inspections.RedundantVisibilityModifierInspection')
    warning('org.jetbrains.kotlin.idea.inspections.AddVarianceModifierInspection')
    info('org.jetbrains.java.generate.inspection.ClassHasNoToStringMethodInspection')
}

In this case both inspections from manually defined list and inherited from IDEA will be in use.

To run inspections, execute from terminal: gradlew inspectionsMain. This will download IDEA artifact to gradle cache, unzip it to cached temporary dir and launch all inspections. You will see inspection messages in console as well as in report XML / HTML located in build/reports/inspections.

Auto-formatting

Auto formatting of a source code is an experimental feature. To run auto-formatting, execute from terminal: gradlew reformatMain. This will reformat all files from the main source root, if the current code style is violated for them. The current code style is read from IDEA project configuration.

JDK configuration

To run inspections correctly, inspection plugin configures JDK in IDEA used. To do it, values of different environment variables are read:

  • JAVA_HOME: can be used to configure any version of JDK
  • JDK_16: can be used to configure JDK 1.6
  • JDK_17: can be used to configure JDK 1.7
  • JDK_18: can be used to configure JDK 1.8

Path to JDK which is used on your project must be available among these variables.

Additional options

You can specify additional options in inspections closure, e.g.:

inspections {
    errors.max = 5
    warnings.max = 20
    info.max = 10
    ignoreFailures = true
    quiet = true
    warning('org.jetbrains.java.generate.inspection.ClassHasNoToStringMethodInspection') {
        quickFix = true
    }
    reformat.quickFix = true
    plugins.kotlin.version = '1.2.60'
    plugins.kotlin.location = 'https://plugins.jetbrains.com/plugin/download?rel=true&updateId=48409'
    tempDirInHome = true
}

The meaning of the parameters is the following:

  • errors.max: after exceeding the given number of inspection diagnostics with "error" severity, inspection task stops and fails.
  • warnings.max: after exceeding the given number of inspection diagnostics with "warning" severity, inspection task stops and fails.
  • info.max: after exceeding the given number of inspection diagnostics with "info" severity, inspection task stops and fails.
  • ignoreFailures: inspection task never fails (false by default)
  • quiet: do not report inspection messages to console, only to XML / HTML files (false by default)
  • quickFix: apply quick fixes for corresponding inspection (false by default). Quick-fix is applied only if it's unique per warning.
  • reformat.quiet: do not report reformat inspection messages to console, only to XML / HTML files (false by default)
  • reformat.quickFix: apply quick fixes for fixed code-style errors (true by default)
  • plugins.kotlin.version: version of downloading kotlin plugin (by default used bundled to IDEA)
  • plugins.kotlin.location: URL of downloading kotlin plugin
  • tempDirInHome: chooses to store plugin data (like unzipped IDEA or Kotlin plugin) either in home directory (true) or in temp directory (false, default).

If you wish to change location of report file, you should specify it in closure for particular task, e.g.

inspectionsMain {
    reports {
        xml {
            destination file("reportFileName")
        }
        html {
            destination file("reportFileName")
        }
    }
}

Bugs and Problems

You can report issues on the relevant tab: https://github.com/JetBrains/inspection-plugin/issues

It's quite probable that plugin does not work yet in some environment. It may result in various exceptions during IDEA configuration process. If you found such a case, please execute:

gradlew --stop
gradlew --info --stacktrace inspectionsMain > inspections.log

and attach inspections.log to the issue. Also it's very helpful to specify Gradle version, OS and IDEA version used in inspection plugin (which is set in idea.version parameter).

Known bugs / problems at this moment (version 0.3.3):

  • plugin does not work yet with Ultimate IDEA versions, like ideaIU:2017.3
  • analysis of Kotlin JS and common modules is only partially supported
  • Kotlin JVM module with common library in dependencies (like kotlin-stdlib-common or kotlin-test) is configured correctly only in IDEA 2018.2 or later, e.g. IC:2018.2
  • IDEA versions 2019.2 or higher aren't supported

Build and Test

Test code is in testing module.

Must do tasks before :testing:test task:

  • :cli:publishCliPublicationToMavenLocal
  • :runner:publishRunnerPublicationToMavenLocal
  • :plugin:build

NB: for me performing just top-level publishToMavenLocal is enough (Mikhail Glukhikh).

More Repositories

1

kotlin

The Kotlin Programming Language.
Kotlin
45,725
star
2

intellij-community

IntelliJ IDEA Community Edition & IntelliJ Platform
16,452
star
3

compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
Kotlin
14,677
star
4

JetBrainsMono

JetBrains Mono โ€“ the free and open-source typeface for developers
Shell
10,126
star
5

ideavim

IdeaVim โ€“ A Vim engine for JetBrains IDEs
Kotlin
7,980
star
6

Exposed

Kotlin SQL Framework
Kotlin
7,869
star
7

kotlin-native

Kotlin/Native infrastructure
Kotlin
7,048
star
8

ring-ui

A collection of JetBrains Web UI components
TypeScript
3,555
star
9

kotlinconf-app

KotlinConf Schedule Application
Kotlin
2,830
star
10

intellij-platform-plugin-template

Template repository for creating plugins for IntelliJ Platform
Kotlin
2,791
star
11

skija

Java bindings for Skia
Java
2,605
star
12

create-react-kotlin-app

Create React apps using Kotlin with no build configuration
JavaScript
2,477
star
13

projector-docker

Run JetBrains IDEs remotely with Docker
Shell
2,209
star
14

intellij-plugins

Open-source plugins included in the distribution of IntelliJ IDEA Ultimate and other IDEs based on the IntelliJ Platform
Java
2,002
star
15

svg-sprite-loader

Webpack loader for creating SVG sprites.
JavaScript
1,998
star
16

skiko

Kotlin MPP bindings to Skia
C++
1,685
star
17

compose-multiplatform-ios-android-template

Compose Multiplatform iOS+Android Application project template
Kotlin
1,563
star
18

MPS

JetBrains Meta programming System
JetBrains MPS
1,500
star
19

lets-plot

Multiplatform plotting library based on the Grammar of Graphics
Kotlin
1,446
star
20

kotlin-web-site

The Kotlin programming language website
JavaScript
1,413
star
21

intellij-platform-gradle-plugin

Gradle plugin for building plugins for IntelliJ-based IDEs
Kotlin
1,377
star
22

phpstorm-stubs

PHP runtime & extensions header files for PhpStorm
PHP
1,297
star
23

kotlin-wrappers

Kotlin wrappers for popular JavaScript libraries
Kotlin
1,294
star
24

idea-gitignore

.ignore support plugin for IntelliJ IDEA
Kotlin
1,287
star
25

projector-server

Server-side library for running Swing applications remotely
Kotlin
1,230
star
26

resharper-unity

Unity support for both ReSharper and Rider
C#
1,199
star
27

intellij-sdk-docs

IntelliJ SDK Platform Documentation
Markdown
1,181
star
28

xodus

Transactional schema-less embedded database used by JetBrains YouTrack and JetBrains Hub.
Java
1,155
star
29

intellij-scala

Scala plugin for IntelliJ IDEA
Scala
1,137
star
30

kotless

Kotlin Serverless Framework
Kotlin
1,124
star
31

JetBrainsRuntime

Runtime environment based on OpenJDK for running IntelliJ Platform-based products on Windows, macOS, and Linux
Java
1,118
star
32

intellij-sdk-code-samples

Mirror of the IntelliJ SDK Docs Code Samples
Java
980
star
33

js-graphql-intellij-plugin

GraphQL language support for WebStorm, IntelliJ IDEA and other IDEs based on the IntelliJ Platform.
Java
879
star
34

android

Android Plugin for IntelliJ IDEA. This repository is a subset of https://git.jetbrains.org/?p=idea/android.git cut according to GitHub file size limitations.
Kotlin
863
star
35

projector-client

Common and client-related code for running Swing applications remotely
Kotlin
813
star
36

projector-installer

Install, configure and run JetBrains IDEs with Projector Server on Linux or in WSL
Python
810
star
37

Grammar-Kit

Grammar files support & parser/PSI generation for IntelliJ IDEA
Java
688
star
38

Arend

The Arend Proof Assistant
Java
676
star
39

amper

Amper - a build and project configuration tool with a focus on the user experience and the IDE support
Kotlin
621
star
40

markdown

Markdown parser written in kotlin
Kotlin
617
star
41

jediterm

Pure Java Terminal Emulator. Works with SSH and PTY.
Java
611
star
42

compose-multiplatform-template

Compose Multiplatform Application project template
Kotlin
603
star
43

jewel

An implementation of the IntelliJ look and feels in Compose for Desktop
Kotlin
580
star
44

Nitra

Public Nitra repository
Nemerle
549
star
45

lincheck

Framework for testing concurrent data structures
Kotlin
520
star
46

intellij-micropython

Plugin for MicroPython devices in PyCharm and IntelliJ
Python
482
star
47

kotlin-playground

Self-contained component to embed in websites for running Kotlin code
JavaScript
422
star
48

colorSchemeTool

Python
396
star
49

compose-multiplatform-desktop-template

Compose Multiplatform Desktop Application project template
Kotlin
393
star
50

lets-plot-kotlin

Grammar of Graphics for Kotlin
Kotlin
389
star
51

Qodana

๐Ÿ“ Source repository of Qodana Help
388
star
52

rd

Reactive Distributed communication framework for .NET, Kotlin, C++. Inspired by Rider IDE.
C#
373
star
53

java-annotations

Annotations for JVM-based languages.
Java
362
star
54

phpstorm-attributes

PhpStorm specific attributes
PHP
357
star
55

Unity3dRider

Unity JetBrains Rider integration
348
star
56

godot-support

C#
339
star
57

pty4j

Pty for Java
Java
338
star
58

resharper-fsharp

F# support in JetBrains Rider
F#
320
star
59

phpstorm-workshop

Code for the PhpStorm workshop
PHP
287
star
60

awesome-pycharm

A curated list of resources for learning and using PyCharm, a Python IDE from JetBrains
271
star
61

web-types

JSON standard for documenting web component libraries for IDEs, documentation generators and other tools
TypeScript
270
star
62

meta-runner-power-pack

A set of Meta-runners for TeamCity
PowerShell
256
star
63

youtrack-mobile

A iOS and Android client for YouTrack
TypeScript
255
star
64

gradle-changelog-plugin

Plugin for parsing and managing the Changelog in a "keep a changelog" style.
Kotlin
252
star
65

ideolog

Interactive viewer for '.log' files.
Kotlin
250
star
66

qodana-action

โš™๏ธ Scan your Go, Java, Kotlin, PHP, Python, JavaScript, TypeScript, .NET projects at GitHub with Qodana. This repository contains Qodana for Azure, GitHub, CircleCI and Gradle
JavaScript
234
star
67

gradle-idea-ext-plugin

Plugin to store IJ settings in gradle script
Groovy
227
star
68

php-timeline

Notable events of PHP history
222
star
69

resharper-rider-samples

Simple interactive exercises to help learn ReSharper and Rider
C#
221
star
70

la-clojure

Clojure plugin for IntelliJ IDEA
Java
220
star
71

kotlin-compiler-server

Server for executing kotlin code
Kotlin
216
star
72

jdk8u_jdk

Java
210
star
73

jcef

A simple framework for embedding Chromium-based browsers into Java-based applications.
Java
206
star
74

pest-intellij

The official Pest Plugin for PhpStorm / IntelliJ IDEA
Kotlin
195
star
75

youtrack-workflows

YouTrack Custom Workflow Repository
JavaScript
194
star
76

psiviewer

PSI Viewer for IntelliJ IDEA plugin development
Java
175
star
77

svg-mixer

Node.js toolset for generating & transforming SVG images and sprites in modern way
JavaScript
173
star
78

compose-for-web-demos

Historical repository of early Compose for Web effort.
171
star
79

phpstorm-docker-images

Pre-configured Docker images used by PhpStorm team
Dockerfile
170
star
80

rider-efcore

Entity Framework Core UI plugin for JetBrains Rider
Kotlin
169
star
81

jetbrains_guide

JetBrains Guides where Developer Advocacy and the community share ideas.
CSS
168
star
82

kotlin-web-demo

Online mini-IDE for Kotlin
Kotlin
168
star
83

intellij-plugin-verifier

Compatibility verification tool for IntelliJ Platform plugins
Kotlin
165
star
84

intellij-samples

Code that demonstrates various IntelliJ IDEA features
Java
163
star
85

jdk8u_hotspot

C++
159
star
86

resharper-rider-plugin

https://www.jetbrains.com/help/resharper/sdk/
PowerShell
158
star
87

qodana-cli

๐Ÿ”ง JetBrains Qodanaโ€™s official command line tool
Go
154
star
88

teamcity-messages

Python Unit Test Reporting to TeamCity
Python
139
star
89

ruby-type-inference

Dynamic definitions and types provider for ruby static analysis
Kotlin
136
star
90

educational-plugin

Educational plugin to learn and teach programming languages such as Kotlin, Java, Python, JavaScript, and others right inside of JetBrains IntelliJ Platform based IDEs.
Kotlin
134
star
91

resharper-angularjs

ReSharper plugin for AngularJS support
JavaScript
134
star
92

clion-remote

134
star
93

golandtipsandtricks

This is an ever evolving repository for GoLand Tips&Tricks
Go
132
star
94

python-skeletons

The python-skeltons repo is deprecated: use PEP 484 and Typeshed instead
Python
132
star
95

clion-wsl

Shell
130
star
96

phpstorm-phpstan-plugin

PHPStan plugin for PhpStorm
Java
130
star
97

teamcity-docker-samples

TeamCity docker compose samples
Shell
128
star
98

phpstorm-psalm-plugin

Psalm plugin for PhpStorm
Java
126
star
99

jdk8u

Shell
123
star
100

YouTrackSharp

.NET Standard 2.0 Library to access YouTrack API.
C#
123
star