{"id":2608,"date":"2024-08-12T08:43:00","date_gmt":"2024-08-12T12:43:00","guid":{"rendered":"http:\/\/sites.bu.edu\/marcom-team\/?page_id=2608"},"modified":"2025-10-30T13:31:24","modified_gmt":"2025-10-30T17:31:24","slug":"running-code-climate-locally","status":"publish","type":"page","link":"https:\/\/sites.bu.edu\/marcom-team\/departments\/interactive-design\/role-specific-info\/info-for-developers\/running-code-climate-locally\/","title":{"rendered":"Running Code Climate Locally"},"content":{"rendered":"<h1><span style=\"color: #ff0000;\"><strong>NOTE &#8211; This information is archival and no longer supported. <\/span><\/h1>\n<p>If you encounter a repo with a <code>codeclimate.yml<\/code>, please delete it.<\/strong><\/p>\n<hr>\n<h2><span style=\"font-weight: 400;\">Prerequisites<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">To run code climate locally, grab an existing plugin or theme\u2019s .codeclimate.yml file (if you don\u2019t already have one) and place it in the root of your repository:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">For plugins, use the one from the <\/span><a href=\"https:\/\/github.com\/bu-ist\/sample-plugin\/blob\/master\/.codeclimate.yml\"><span style=\"font-weight: 400;\">sample plugin repo<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">For themes, use the one from the <\/span><a href=\"https:\/\/github.com\/bu-ist\/responsive-child-starter\/blob\/develop\/.codeclimate.yml\"><span style=\"font-weight: 400;\">responsive framework\u2019s child-starter<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Next, follow the instructions listed on the <\/span><a href=\"https:\/\/github.com\/codeclimate\/codeclimate\/#prerequisites\"><span style=\"font-weight: 400;\">Code Climate repo<\/span><\/a><span style=\"font-weight: 400;\">, or continue by installing the prerequisites that are listed:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/www.docker.com\/\"><span style=\"font-weight: 400;\">Docker<\/span><\/a><span style=\"font-weight: 400;\">, or use <\/span><a href=\"https:\/\/docs.docker.com\/docker-for-mac\/\"><span style=\"font-weight: 400;\">Docker for Mac<\/span><\/a><span style=\"font-weight: 400;\"> for macOS.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/brew.sh\/\"><span style=\"font-weight: 400;\">Homebrew<\/span><\/a><span style=\"font-weight: 400;\"> (only if on macOS)<\/span><\/li>\n<\/ul>\n<h2><span style=\"font-weight: 400;\">Installation<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Note: All of this information is available on the <\/span><a href=\"https:\/\/github.com\/codeclimate\/codeclimate\/#prerequisites\"><span style=\"font-weight: 400;\">Code Climate repo<\/span><\/a><span style=\"font-weight: 400;\">. To continue, make sure you have <\/span><a href=\"https:\/\/www.docker.com\/\"><span style=\"font-weight: 400;\">Docker<\/span><\/a><span style=\"font-weight: 400;\">, or <\/span><a href=\"https:\/\/docs.docker.com\/docker-for-mac\/\"><span style=\"font-weight: 400;\">Docker for Mac<\/span><\/a><span style=\"font-weight: 400;\"> for macOS.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">1. Install Docker Image<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">To run Code Climate reports locally, the Docker image must be installed on your machine.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Run the following command in a Terminal session to pull down the Docker image:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">docker pull codeclimate\/codeclimate<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This will download the Docker image that code climate will use to run its analysis tools.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">After that finishes, code climate can now be run using the following example command:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">docker run \\<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0&#8211;interactive &#8211;tty &#8211;rm \\<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0&#8211;env CODECLIMATE_CODE=&#8221;$PWD&#8221; \\<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0&#8211;volume &#8220;$PWD&#8221;:\/code \\<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0&#8211;volume \/var\/run\/docker.sock:\/var\/run\/docker.sock \\<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0&#8211;volume \/tmp\/cc:\/tmp\/cc \\<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0codeclimate\/codeclimate help<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">But since that\u2019s a burden to type each time, it is preferred to use Code Climate\u2019s wrapper scripts. Follow either of the options in step 2 to install the codeclimate command.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">2. Install codeclimate command<\/span><\/h3>\n<h4><span style=\"font-weight: 400;\">For macOS using Homebrew<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">The easiest way to install the codeclimate command on macOS is with the homebrew package manager. <\/span><a href=\"https:\/\/brew.sh\/\"><span style=\"font-weight: 400;\">Install homebrew before continuing<\/span><\/a><span style=\"font-weight: 400;\">. Otherwise, continue on to the next step.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In a Terminal session, run the following commands:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">brew tap codeclimate\/formulae<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">brew install codeclimate<\/span><\/li>\n<\/ol>\n<h4><span style=\"font-weight: 400;\">For any OS (Windows, Linux, etc)<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">If on Windows or another operating system, run the following commands:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">curl -L https:\/\/github.com\/codeclimate\/codeclimate\/archive\/master.tar.gz | tar xvz<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">cd codeclimate-* &amp;&amp; sudo make install<\/span><\/li>\n<\/ol>\n<h2><span style=\"font-weight: 400;\">Usage<\/span><\/h2>\n<h3><span style=\"font-weight: 400;\">Example commands<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">If using the wrapper scripts, the codeclimate command should be available. Test it by running codeclimate version.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">A list of commands is available on the <\/span><a href=\"https:\/\/github.com\/codeclimate\/codeclimate\/#commands\"><span style=\"font-weight: 400;\">Code Climate GitHub page<\/span><\/a><span style=\"font-weight: 400;\">. The following commands can be run in the root of your repository:<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Analyze the entire repo<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">codeclimate analyze<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Analyze just one file<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">codeclimate analyze includes\/functions.php<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Validate the contents of your codeclimate file<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">codeclimate validate-config<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">Troubleshooting<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">You can debug and modify how your commands run by adding additional flags. See the <\/span><a href=\"https:\/\/github.com\/codeclimate\/codeclimate#environment-variables\"><span style=\"font-weight: 400;\">Code Climate repo<\/span><\/a><span style=\"font-weight: 400;\"> for official definitions of each flag. As an overview, these are the following known flags:<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Run codeclimate in debug mode<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">CODECLIMATE_DEBUG=1 codeclimate analyze<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Prints additional information about the analysis steps, including any stderr produced by engines.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Increase timeout<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">To increase the amount of time each engine container may run (default 15 min):<\/span><\/p>\n<p><span style=\"font-weight: 400;\"># 30 minutes<\/span><\/p>\n<p><span style=\"font-weight: 400;\">CONTAINER_TIMEOUT_SECONDS=1800 codeclimate analyze<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Increase memory<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">You can also configure the default alotted memory with which each engine runs (default is 1,024,000,000 bytes):<\/span><\/p>\n<p><span style=\"font-weight: 400;\"># 2,000,000,000 bytes<\/span><\/p>\n<p><span style=\"font-weight: 400;\">ENGINE_MEMORY_LIMIT_BYTES=2000000000 codeclimate analyze<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">The analyze script is taking forever to run<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">This could be due to a variety of factors:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">It could be hanging up on installing engines. Try running codeclimate engines:install first, before running codeclimate analyze<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">There are a very large number of files in your repository that Code Climate is trying to analyze at once. Be sure to specify all files and directories you want Code Climate to skip using the exclude_patterns key in the yaml config file.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">It could be hanging up on some assets that its trying to download in the prepare &gt; fetch key in the yaml config file. Make sure the repos are all public.<\/span><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>NOTE &#8211; This information is archival and no longer supported. If you encounter a repo with a codeclimate.yml, please delete it. Prerequisites To run code climate locally, grab an existing plugin or theme\u2019s .codeclimate.yml file (if you don\u2019t already have one) and place it in the root of your repository: For plugins, use the one [&hellip;]<\/p>\n","protected":false},"author":12906,"featured_media":0,"parent":230,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/sites.bu.edu\/marcom-team\/wp-json\/wp\/v2\/pages\/2608"}],"collection":[{"href":"https:\/\/sites.bu.edu\/marcom-team\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/sites.bu.edu\/marcom-team\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/sites.bu.edu\/marcom-team\/wp-json\/wp\/v2\/users\/12906"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.bu.edu\/marcom-team\/wp-json\/wp\/v2\/comments?post=2608"}],"version-history":[{"count":13,"href":"https:\/\/sites.bu.edu\/marcom-team\/wp-json\/wp\/v2\/pages\/2608\/revisions"}],"predecessor-version":[{"id":4074,"href":"https:\/\/sites.bu.edu\/marcom-team\/wp-json\/wp\/v2\/pages\/2608\/revisions\/4074"}],"up":[{"embeddable":true,"href":"https:\/\/sites.bu.edu\/marcom-team\/wp-json\/wp\/v2\/pages\/230"}],"wp:attachment":[{"href":"https:\/\/sites.bu.edu\/marcom-team\/wp-json\/wp\/v2\/media?parent=2608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}