— To migrate an existing account, please see our Migration Guide.
Whether you've started working on a plugin or are just curious what goes into making a new analysis tool work on the Code Climate Platform, this document is for you.
In order to understand how to build a Code Climate plugin, we thought it would be helpful to start with a working definition:
A Code Climate Plugin is a Docker Image that invokes a program which parses a config file and analyzes files, potentially producing formatted output representing issues in those files.
Within that definition are some bolded words which could use some elaboration.
Before we dig in, this is a good time to state that that the design, packaging, and operation of an plugin is guided by the Code Climate Spec, and Quality Assurance steps are outlined in the Plugin QA spreadsheet.
.codeclimate.yml
file ends up in this config file, and includes data like which files to analyze, how to configure the plugin, etc.Once you've read the "How to build an plugin" blog post, looked at the Spec, seen the QA spreadsheet, and maybe even browsed around a few example plugins, you still may not know what a good approach is to getting started.
Here are some tips that we've given to a number of plugin authors. We think they're good inspiration for getting started with what can seem like a daunting task. If they help, let us know! If they don't, hey, let us know too! We'd love to make this list as complete as possible.
Docker is an essential aspect of our platform - the whole thing basically runs on it. To that end, you need to have a fully functioning Docker environment running locally, and you need to understand the basics of making a Docker Image to correctly build a Code Climate Plugin. That being said, it can wait.
You can get started with the basics of your plugin, like making a simple script, studying plugins, etc., before you worry about making your own Dockerfile
, and besides, in all likelihood you'll be able to copy an existing plugin's implementation for most of what you need.
So if the Docker work is scaring you off, don't let it. Support for Docker is becoming better and better on all widely deployed Desktop environments, educational material is abundant, and much of the work ahead you has been done for you.
Once you're ready to build your plugin, we recommend as a first step that you build a simple script that can accomplish the following:
config_file_path
and workspace_path
config_file_path
parameter to find and parse a file named config.json
, and store its keys and values in a data structureinclude_paths
key from the parsed config.json
file and the workspace_path
parameterSTDOUT
Parsing a config, executing the tool, and formatting the output comprise the majority of the functionality of a Code Climate engine. Once you have a script which can accomplish these things, you're most of the way there!
All Code Climate plugins are Open Source. Feel free to fork any of the plugins available in our list of plugins and use it as the basis for your own work.
If you're building plugins in pretty much any major programming language, we have examples for you to be inspired by. There are even libraries in certain languages for making writing plugins even easier.
The Code Climate CLI ships with a few handy tricks for making plugin development easier:
--dev
flag - when you want to test your plugin with the CLI, add it to the .codeclimate.yml
file of a project, and run codeclimate analyze --dev
. The --dev
flag will allow the CLI to check locally for plugin Docker Images, letting you specify plugins that aren't generally available.-f json
flag - if your issues are breaking the standard output or you want to see parts that aren't represented there, you can make the CLI output JSON, which shows all available fieldsCODECLIMATE_DEBUG=1 codeclimate analyze
The CLI looks for the presence of an environment variable called CODECLIMATE_DEBUG
and outputs extra useful debugging information if it finds it. This can save you lots of time!If you've come across any other good tips, let us know!
The Code Climate CLI has an HTML output flag that will show you rendered markdown for issue descriptions and content. To use the HTML formatter, run codeclimate analyze -f html > out.html
and inspecting out.html
in a browser.
Join our Code Climate Developer Slack Channel! You should get an invitation automatically when you join the Developer Program.
" style="margin-left:31px" class="rm-Markdown markdown-body rm-Markdown markdown-body ng-non-bindable" data-testid="RDMD">Code Climate Quality is being replaced with Qlty Cloud
— New users should sign up directly at qlty.sh.
— To migrate an existing account, please see our Migration Guide.
Whether you've started working on a plugin or are just curious what goes into making a new analysis tool work on the Code Climate Platform, this document is for you.
In order to understand how to build a Code Climate plugin, we thought it would be helpful to start with a working definition:
A Code Climate Plugin is a Docker Image that invokes a program which parses a config file and analyzes files, potentially producing formatted output representing issues in those files.
Within that definition are some bolded words which could use some elaboration.
Before we dig in, this is a good time to state that that the design, packaging, and operation of an plugin is guided by the Code Climate Spec, and Quality Assurance steps are outlined in the Plugin QA spreadsheet.
.codeclimate.yml
file ends up in this config file, and includes data like which files to analyze, how to configure the plugin, etc.Once you've read the "How to build an plugin" blog post, looked at the Spec, seen the QA spreadsheet, and maybe even browsed around a few example plugins, you still may not know what a good approach is to getting started.
Here are some tips that we've given to a number of plugin authors. We think they're good inspiration for getting started with what can seem like a daunting task. If they help, let us know! If they don't, hey, let us know too! We'd love to make this list as complete as possible.
Docker is an essential aspect of our platform - the whole thing basically runs on it. To that end, you need to have a fully functioning Docker environment running locally, and you need to understand the basics of making a Docker Image to correctly build a Code Climate Plugin. That being said, it can wait.
You can get started with the basics of your plugin, like making a simple script, studying plugins, etc., before you worry about making your own Dockerfile
, and besides, in all likelihood you'll be able to copy an existing plugin's implementation for most of what you need.
So if the Docker work is scaring you off, don't let it. Support for Docker is becoming better and better on all widely deployed Desktop environments, educational material is abundant, and much of the work ahead you has been done for you.
Once you're ready to build your plugin, we recommend as a first step that you build a simple script that can accomplish the following:
config_file_path
and workspace_path
config_file_path
parameter to find and parse a file named config.json
, and store its keys and values in a data structureinclude_paths
key from the parsed config.json
file and the workspace_path
parameterSTDOUT
Parsing a config, executing the tool, and formatting the output comprise the majority of the functionality of a Code Climate engine. Once you have a script which can accomplish these things, you're most of the way there!
All Code Climate plugins are Open Source. Feel free to fork any of the plugins available in our list of plugins and use it as the basis for your own work.
If you're building plugins in pretty much any major programming language, we have examples for you to be inspired by. There are even libraries in certain languages for making writing plugins even easier.
The Code Climate CLI ships with a few handy tricks for making plugin development easier:
--dev
flag - when you want to test your plugin with the CLI, add it to the .codeclimate.yml
file of a project, and run codeclimate analyze --dev
. The --dev
flag will allow the CLI to check locally for plugin Docker Images, letting you specify plugins that aren't generally available.-f json
flag - if your issues are breaking the standard output or you want to see parts that aren't represented there, you can make the CLI output JSON, which shows all available fieldsCODECLIMATE_DEBUG=1 codeclimate analyze
The CLI looks for the presence of an environment variable called CODECLIMATE_DEBUG
and outputs extra useful debugging information if it finds it. This can save you lots of time!If you've come across any other good tips, let us know!
The Code Climate CLI has an HTML output flag that will show you rendered markdown for issue descriptions and content. To use the HTML formatter, run codeclimate analyze -f html > out.html
and inspecting out.html
in a browser.
Join our Code Climate Developer Slack Channel! You should get an invitation automatically when you join the Developer Program.
Updated about 2 months ago