Qodana 2021.3 Help

Clone Finder Docker image

official JetBrains project Docker Stars Docker Pulls

Supported tags: 2021.1-eap, latest (points to 2021.1-eap)

We provide a Docker image for the Clone Finder linter to support different usage scenarios:

  • Running the analysis on a regular basis as part of your continuous integration (CI-based execution)

  • Single-shot analysis (for example, performed locally).

Quick start

Run analysis locally

  1. Pull the image from Docker Hub (necessary to use the latest version):

    docker pull jetbrains/qodana-clone-finder
  2. Run the following command:

    docker run --rm -it -p 8080:8080 \ -v <queried-project-directory>/:/data/project/ \ -v <reference-projects-directory>/:/data/versus/ \ -v <output-directory>/:/data/results/ \ jetbrains/qodana-clone-finder --show-report

where <queried-project-directory>, <reference-projects-directory>, and <output-directory> are full local paths to the directories that contain, respectively, the project source code, one or more projects to compare against, and the analysis results.

Example of project structure:

/ ├── project │   └── project_source_code └── versus ├── project1 │   └── source_code └── project2 │   └── source_code ...

This command runs the analysis on your source code and starts the web server to provide a convenient view of the results. Open http://localhost:8080 in your browser to examine the found problems and performed checks. Here, you can also reconfigure the analysis. See the UI section of this guide for details. When done, you can stop the web server by pressing Ctrl-C in the Docker console.

In case you don't need the user interface and prefer to study raw data, use the following command:

docker run --rm -it \ -v <source-directory>/:/data/project/ \ -v <queried-projects-directory>/:/data/versus/ \ -v <output-directory>/:/data/results/ \ jetbrains/qodana-clone-finder

The <output-directory> will contain all the necessary results. You can further tune the command as described in the technical guide.

If you run the analysis several times in a row, make sure you've cleaned the results directory before using it in docker run again.

By default, Qodana Clone Finder searches clones in all supported languages but you can explicitly specify languages to search. See technical guide for details.

If reference projects are not located under the same root directory, you can use the following options to map them inside the container: -v "<local path to project for comparison>/<project name>:/data/versus/<project name>"

Example:

docker run --rm -it -p 8080:8080\ -v <project_folder>/project/:/data/project/ \ -v /somepath/versus_project1/:/data/versus/project1/ \ -v /anotherpath/versus_project2/:/data/versus/project2/ \ jetbrains/qodana-clone-finder --show-report

Run analysis in CI

  • Run the following command as a task in a generic Shell executor:

    docker run --rm -it \ -v <queried-project-directory>/:/data/project/ \ -v <reference-projects-directory>/:/data/versus/ \ -v <output-directory>/:/data/results/ \ jetbrains/qodana-clone-finder

where <queried-project-directory>, <reference-projects-directory>, and <output-directory> are full paths to the directories that contain, respectively, the project source code, one or more projects to compare against, and the analysis results.

The content of <output-directory> is described in Clone Finder Output. Consider using fail-threshold to make the build fail on reaching a certain number of problems. Running as non-root is also supported.

  • Example for GitHub Workflow (.github/workflows/clone-finder-qodana.yml):

name: Qodana - Clone Finder on: workflow_dispatch: jobs: qodana: runs-on: ubuntu-latest steps: # clone your project to ./project/ - uses: actions/checkout@v2 with: path: ./project/ # clone the repositories to ./versus/ - uses: actions/checkout@v2 with: repository: JetBrains-Research/buckwheat path: ./versus/buckwheat # run qodana-clone-finder - name: Qodana - Clone Finder uses: jetbrains/qodana-clone-finder-action@main - uses: actions/upload-artifact@v2 with: path: ${{ github.workspace }}/qodana

Usage statistics

According to the JetBrains EAP user agreement, we can use third-party services to analyze the usage of our features to further improve the user experience. All data will be collected anonymously. You can disable the reporting of usage statistics by adjusting the options of the Docker command you use. Refer to the technical guide for details.

License

By using Qodana Clone Finder Docker image, you agree to the JetBrains EAP user agreement and JetBrains privacy policy.

Last modified: 12 May 2022