• Stars
    star
    164
  • Rank 228,226 (Top 5 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 2 years ago
  • Updated 2 months ago

Reviews

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

Repository Details

🔧 JetBrains Qodana’s official command line tool

Qodana CLI

JetBrains project Qodana GoReport GitHub Discussions Twitter Follow

qodana is a simple cross-platform command-line tool to run Qodana linters anywhere with minimum effort required.

tl;dr

Install and run:

qodana scan --show-report

You can also add the linter by its name with the --linter option (e.g. --linter jetbrains/qodana-js).

Table of Contents

qodana

Installation

💡 The Qodana CLI is distributed and run as a binary. The Qodana linters with inspections are Docker Images.

macOS and Linux

Install with Homebrew (recommended)
brew install jetbrains/utils/qodana
Install with our installer
curl -fsSL https://jb.gg/qodana-cli/install | bash

Windows

Install with Windows Package Manager (recommended)
winget install -e --id JetBrains.QodanaCLI
Install with Chocolatey
choco install qodana
Install with Scoop
scoop bucket add jetbrains https://github.com/JetBrains/scoop-utils
scoop install qodana

Anywhere else

Alternatively, you can install the latest binary (or the apt/rpm/deb package) from this page.

Usage

Get.Started.with.Qodana.CLI.mp4

🎥 The "Get Started with Qodana CLI" video is also available on YouTube.

Prepare your project

Before you start using Qodana, you need to configure your project – choose a linter to use. If you know what linter you want to use, you can skip this step.

Also, Qodana CLI can choose a linter for you. Just run the following command in your project root:

qodana init

Analyze your project

Right after you configured your project (or remember linter's name you want to run), you can run Qodana inspections simply by invoking the following command in your project root:

qodana scan
  • After the first Qodana run, the following runs will be faster because of the saved Qodana cache in your project (defaults to ./<userCacheDir>/JetBrains/<linter>/cache)
  • The latest Qodana report will be saved to ./<userCacheDir>/JetBrains/<linter>/results – you can find qodana.sarif.json and other Qodana artifacts (like logs) in this directory.

View the report

After the analysis, the results are saved to ./<userCacheDir>/JetBrains/<linter>/results by default. Inside the directory ./<userCacheDir>/JetBrains/<linter>/results/report, you can find a Qodana HTML report. To view it in the browser, run the following command from your project root:

qodana show

You can serve any Qodana HTML report regardless of the project if you provide the correct report path.

Configuration

To find more CLI options run qodana ... commands with the --help flag. If you want to configure Qodana or a check inside Qodana, consider using qodana.yaml to have the same configuration on any CI you use and your machine.

In some flags help texts you can notice that the default path contains <userCacheDir>/JetBrains. The <userCacheDir> differs from the OS you are running Qodana with.

  • macOS: ~/Library/Caches/
  • Linux: ~/.cache/
  • Windows: %LOCALAPPDATA%\ Also, you can just run qodana show -d to open the directory with the latest Qodana report.

init

Configure a project for Qodana

Synopsis

Configure a project for Qodana: prepare Qodana configuration file by analyzing the project structure and generating a default configuration qodana.yaml file.

qodana init [flags]

Options

  -f, --force                Force initialization (overwrite existing valid qodana.yaml)
  -h, --help                 help for init
  -i, --project-dir string   Root directory of the project to configure (default ".")

scan

Scan project with Qodana

Synopsis

Scan a project with Qodana. It runs one of Qodana Docker's images (https://www.jetbrains.com/help/qodana/docker-images.html) and reports the results.

Note that most options can be configured via qodana.yaml (https://www.jetbrains.com/help/qodana/qodana-yaml.html) file. But you can always override qodana.yaml options with the following command-line options.

qodana scan [flags]

Options

  -l, --linter string             Override linter to use
  -i, --project-dir string        Root directory of the inspected project (default ".")
  -o, --results-dir string        Override directory to save Qodana inspection results to (default <userCacheDir>/JetBrains/<linter>/results)
      --cache-dir string          Override cache directory (default <userCacheDir>/JetBrains/<linter>/cache)
  -e, --env stringArray           Define additional environment variables for the Qodana container (you can use the flag multiple times). CLI is not reading full host environment variables and does not pass it to the Qodana container for security reasons
  -v, --volume stringArray        Define additional volumes for the Qodana container (you can use the flag multiple times)
  -u, --user string               User to run Qodana container as. Please specify user id – '$UID' or user id and group id $(id -u):$(id -g). Use 'root' to run as the root user (default: the current user)
      --skip-pull                 Skip pulling the latest Qodana container
      --print-problems            Print all found problems by Qodana in the CLI output
      --clear-cache               Clear the local Qodana cache before running the analysis
  -w, --show-report               Serve HTML report on port
      --port int                  Port to serve the report on (default 8080)
  -a, --analysis-id string        Unique report identifier (GUID) to be used by Qodana Cloud
  -b, --baseline string           Provide the path to an existing SARIF report to be used in the baseline state calculation
      --baseline-include-absent   Include in the output report the results from the baseline run that are absent in the current run
      --commit string             Base changes commit to reset to, useful with --script local-changes: analysis will be run only on changed files since commit X, 'reset' will be cancelled once the analysis is finished if the commit prefix does not contain CI prefix
      --fail-threshold string     Set the number of problems that will serve as a quality gate. If this number is reached, the inspection run is terminated with a non-zero exit code
      --disable-sanity            Skip running the inspections configured by the sanity profile
  -d, --source-directory string   Directory inside the project-dir directory must be inspected. If not specified, the whole project is inspected
  -n, --profile-name string       Profile name defined in the project
  -p, --profile-path string       Path to the profile file
      --run-promo string          Set to 'true' to have the application run the inspections configured by the promo profile; set to 'false' otherwise (default: 'true' only if Qodana is executed with the default profile)
      --script string             Override the run scenario (default "default")
      --stub-profile string       Absolute path to the fallback profile file. This option is applied in case the profile was not specified using any available options
      --property stringArray      Set a JVM property to be used while running Qodana using the --property property.name=value1,value2,...,valueN notation
  -s, --save-report               Generate HTML report (default true)
  -h, --help                      help for scan

show

Show a Qodana report

Synopsis

Show (serve) the latest Qodana report.

Due to JavaScript security restrictions, the generated report cannot be viewed via the file:// protocol (by double-clicking the index.html file).
https://www.jetbrains.com/help/qodana/html-report.html This command serves the Qodana report locally and opens a browser to it.

qodana show [flags]

Options

  -d, --dir-only             Open report directory only, don't serve it
  -h, --help                 help for show
  -l, --linter string        Override linter to use
  -p, --port int             Specify port to serve report at (default 8080)
  -i, --project-dir string   Root directory of the inspected project (default ".")
  -r, --report-dir string    Specify HTML report path (the one with index.html inside) (default <userCacheDir>/JetBrains/<linter>/results/report)

view

View SARIF files in CLI

Synopsis

Preview all problems found in SARIF files in CLI.

qodana view [flags]

Options

  -h, --help                help for view
  -f, --sarif-file string   Path to the SARIF file (default "./qodana.sarif.json")

contributors

A command-line helper for Qodana pricing to calculate active contributors* in the given repository.

Synopsis

  • An active contributor is anyone who has made a commit to any of the projects you’ve registered in Qodana Cloud within the last 90 days, regardless of when those commits were originally authored. The number of such contributors will be calculated using both the commit author information and the timestamp for when their contribution to the project was pushed.

** Ultimate Plus plan currently has a discount, more information can be found on https://www.jetbrains.com/qodana/buy/

qodana contributors [flags]

Options

  -d, --days int             Number of days since when to calculate the number of active contributors (default 30)
  -h, --help                 help for contributors
  -i, --project-dir string   Root directory of the inspected project (default ".")

cloc

A command-line helper for project statistics: languages, lines of code. Powered by boyter/scc. For contributors, use "qodana contributors" command.

Synopsis

qodana cloc [flags]

Options

  -h, --help                      help for cloc
  -o, --output string             Output format, can be [tabular, wide, json, csv, csv-stream, cloc-yaml, html, html-table, sql, sql-insert, openmetrics] (default "tabular")
  -i, --project-dir stringArray   Project directory, can be specified multiple times to check multiple projects, if not specified, current directory will be used

Why

Comics by Irina Khromova

🖼 Irina Khromova painted the illustration

Qodana linters are distributed via Docker images – which become handy for developers (us) and users to run code inspections in CI.

But to set up Qodana in CI, one wants to try it locally first, as there is some additional configuration tuning required that differs from project to project (and we try to be as much user-friendly as possible).

It's easy to try Qodana locally by running a simple command:

docker run --rm -it -p 8080:8080 -v <source-directory>/:/data/project/ -v <output-directory>/:/data/results/ -v <caches-directory>/:/data/cache/ jetbrains/qodana-<linter> --show-report

And that's not so simple: you have to provide a few absolute paths, forward some ports, add a few Docker options...

  • On Linux, you might want to set the proper permissions to the results produced after the container run – so you need to add an option like -u $(id -u):$(id -g)
  • On Windows and macOS, when there is the default Docker Desktop RAM limit (2GB), your run might fail because of OOM (and this often happens on big Gradle projects on Gradle sync), and the only workaround, for now, is increasing the memory – but to find that out, one needs to look that up in the docs.
  • That list could go on, but we've thought about these problems, experimented a bit, and created the CLI to simplify all of this.

Isn't that a bit overhead to write a tool that runs Docker containers when we have Docker CLI already? Our CLI, like Docker CLI, operates with Docker daemon via Docker Engine API using the official Docker SDK, so actually, our tool is our own tailored Docker CLI at the moment.

More Repositories

1

kotlin

The Kotlin Programming Language.
Kotlin
48,712
star
2

intellij-community

IntelliJ IDEA Community Edition & IntelliJ Platform
Java
16,958
star
3

compose-multiplatform

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

JetBrainsMono

JetBrains Mono – the free and open-source typeface for developers
Shell
10,765
star
5

Exposed

Kotlin SQL Framework
Kotlin
8,128
star
6

ideavim

IdeaVim – A Vim engine for JetBrains IDEs
Kotlin
7,980
star
7

kotlin-native

Kotlin/Native infrastructure
Kotlin
7,026
star
8

ring-ui

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

intellij-platform-plugin-template

Template repository for creating plugins for IntelliJ Platform
Kotlin
3,009
star
10

kotlinconf-app

KotlinConf Schedule Application
Kotlin
2,955
star
11

skija

Java bindings for Skia
Java
2,619
star
12

create-react-kotlin-app

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

projector-docker

Run JetBrains IDEs remotely with Docker
Shell
2,215
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 Multiplatform bindings to Skia
C++
1,788
star
17

compose-multiplatform-ios-android-template

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

lets-plot

Multiplatform plotting library based on the Grammar of Graphics
Kotlin
1,534
star
19

MPS

JetBrains Meta programming System
JetBrains MPS
1,527
star
20

kotlin-web-site

The Kotlin programming language website
JavaScript
1,458
star
21

intellij-platform-gradle-plugin

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

kotlin-wrappers

Kotlin wrappers for popular JavaScript libraries
Kotlin
1,329
star
23

phpstorm-stubs

PHP runtime & extensions header files for PhpStorm
PHP
1,309
star
24

idea-gitignore

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

JetBrainsRuntime

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

projector-server

Server-side library for running Swing applications remotely
Kotlin
1,241
star
27

intellij-sdk-docs

IntelliJ SDK Platform Documentation
Markdown
1,209
star
28

resharper-unity

Unity support for both ReSharper and Rider
C#
1,208
star
29

intellij-scala

Scala plugin for IntelliJ IDEA
Scala
1,180
star
30

xodus

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

kotless

Kotlin Serverless Framework
Kotlin
1,147
star
32

intellij-sdk-code-samples

Mirror of the IntelliJ SDK Docs Code Samples
Java
1,060
star
33

amper

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

js-graphql-intellij-plugin

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

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
36

projector-installer

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

projector-client

Common and client-related code for running Swing applications remotely
Kotlin
809
star
38

Grammar-Kit

Grammar files support & parser/PSI generation for IntelliJ IDEA
Java
706
star
39

Arend

The Arend Proof Assistant
Java
690
star
40

jediterm

Pure Java Terminal Emulator. Works with SSH and PTY.
Java
675
star
41

jewel

An implementation of the IntelliJ look and feels in Compose for Desktop
Kotlin
670
star
42

markdown

Markdown parser written in kotlin
Kotlin
669
star
43

compose-multiplatform-template

Compose Multiplatform Application project template
Kotlin
620
star
44

lincheck

Framework for testing concurrent data structures
Kotlin
560
star
45

Nitra

Public Nitra repository
Nemerle
549
star
46

intellij-micropython

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

kotlin-playground

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

compose-multiplatform-desktop-template

Compose Multiplatform Desktop Application project template
Kotlin
429
star
49

lets-plot-kotlin

Grammar of Graphics for Kotlin
Kotlin
420
star
50

colorSchemeTool

Python
396
star
51

java-annotations

Annotations for JVM-based languages.
Java
395
star
52

Qodana

📝 Source repository of Qodana Help
390
star
53

phpstorm-attributes

PhpStorm specific attributes
PHP
384
star
54

rd

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

godot-support

C#
359
star
56

pty4j

Pty for Java
Java
351
star
57

Unity3dRider

Unity JetBrains Rider integration
349
star
58

resharper-fsharp

F# support in JetBrains Rider
F#
328
star
59

phpstorm-workshop

Code for the PhpStorm workshop
PHP
287
star
60

web-types

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

awesome-pycharm

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

youtrack-mobile

A iOS and Android client for YouTrack
TypeScript
263
star
63

gradle-changelog-plugin

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

meta-runner-power-pack

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

inspection-plugin

Gradle plugin to launch IDEA inspections
Kotlin
256
star
66

ideolog

Interactive viewer for '.log' files.
Kotlin
255
star
67

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
248
star
68

jcef

A simple framework for embedding Chromium-based browsers into Java-based applications.
Java
238
star
69

kotlin-compiler-server

Server for executing kotlin code
Kotlin
236
star
70

gradle-idea-ext-plugin

Plugin to store IJ settings in gradle script
Groovy
229
star
71

resharper-rider-samples

Simple interactive exercises to help learn ReSharper and Rider
C#
225
star
72

php-timeline

Notable events of PHP history
222
star
73

la-clojure

Clojure plugin for IntelliJ IDEA
Java
220
star
74

jdk8u_jdk

Java
211
star
75

pest-intellij

The official Pest Plugin for PhpStorm / IntelliJ IDEA
Kotlin
197
star
76

youtrack-workflows

YouTrack Custom Workflow Repository
JavaScript
194
star
77

psiviewer

PSI Viewer for IntelliJ IDEA plugin development
Java
181
star
78

compose-for-web-demos

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

rider-efcore

Entity Framework Core UI plugin for JetBrains Rider
Kotlin
174
star
80

svg-mixer

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

intellij-plugin-verifier

Compatibility verification tool for IntelliJ Platform plugins
Kotlin
171
star
82

phpstorm-docker-images

Pre-configured Docker images used by PhpStorm team
Dockerfile
171
star
83

kotlin-web-demo

Online mini-IDE for Kotlin
Kotlin
167
star
84

resharper-rider-plugin

https://www.jetbrains.com/help/resharper/sdk/
PowerShell
166
star
85

jetbrains_guide

JetBrains Guides where Developer Advocacy and the community share ideas.
CSS
165
star
86

intellij-samples

Code that demonstrates various IntelliJ IDEA features
Java
165
star
87

jdk8u_hotspot

C++
159
star
88

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
143
star
89

teamcity-messages

Python Unit Test Reporting to TeamCity
Python
139
star
90

ruby-type-inference

Dynamic definitions and types provider for ruby static analysis
Kotlin
137
star
91

clion-remote

134
star
92

resharper-angularjs

ReSharper plugin for AngularJS support
JavaScript
134
star
93

YouTrackSharp

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

golandtipsandtricks

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

python-skeletons

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

phpstorm-phpstan-plugin

PHPStan plugin for PhpStorm
Java
131
star
97

clion-wsl

Shell
130
star
98

lets-plot-skia

Skia frontend for Lets-Plot multiplatform plotting library.
Kotlin
130
star
99

UnrealLink

C++
128
star
100

teamcity-docker-samples

TeamCity docker compose samples
Shell
128
star