{"id":13411663,"url":"https://github.com/fastruby/skunk","last_synced_at":"2025-05-15T15:05:26.605Z","repository":{"id":35208586,"uuid":"215086062","full_name":"fastruby/skunk","owner":"fastruby","description":"A SkunkScore Calculator for Ruby Code -- Find the most complicated code without test coverage!","archived":false,"fork":false,"pushed_at":"2024-03-02T20:45:54.000Z","size":285,"stargazers_count":511,"open_issues_count":11,"forks_count":29,"subscribers_count":9,"default_branch":"main","last_synced_at":"2024-10-01T10:18:18.731Z","etag":null,"topics":["code-coverage","code-quality","code-quality-analyzer","good-first-issue","hacktoberfest","skunk-score"],"latest_commit_sha":null,"homepage":"https://www.fastruby.io/blog/code-quality/intruducing-skunk-stink-score-calculator.html","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fastruby.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-14T15:58:02.000Z","updated_at":"2024-09-14T05:18:24.000Z","dependencies_parsed_at":"2023-12-01T20:36:03.587Z","dependency_job_id":"2be84de1-ccf7-4978-b9f9-c4e79d3130ef","html_url":"https://github.com/fastruby/skunk","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastruby%2Fskunk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastruby%2Fskunk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastruby%2Fskunk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastruby%2Fskunk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastruby","download_url":"https://codeload.github.com/fastruby/skunk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247721898,"owners_count":20985084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-coverage","code-quality","code-quality-analyzer","good-first-issue","hacktoberfest","skunk-score"],"created_at":"2024-07-30T20:01:15.525Z","updated_at":"2025-05-15T15:05:26.599Z","avatar_url":"https://github.com/fastruby.png","language":"Ruby","readme":"# Skunk\n\n![skunk](logo.png)\n\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v1.4%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md) [![Build Status](https://travis-ci.org/fastruby/skunk.svg?branch=master)](https://travis-ci.org/fastruby/skunk) [![Maintainability](https://api.codeclimate.com/v1/badges/3e33d701ced16eee2420/maintainability)](https://codeclimate.com/github/fastruby/skunk/maintainability) [![Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/gems/skunk) [![codecov](https://codecov.io/gh/fastruby/skunk/branch/master/graph/badge.svg)](https://codecov.io/gh/fastruby/skunk)\n\nSkunk is a RubyCritic extension to calculate a SkunkScore for a file or project. The SkunkScore is a value that assesses the technical debt of a module.\n\n## Table of contents\n* [What is the SkunkScore?](#what-is-the-skunkscore)\n* [Getting started](#getting-started)\n    * [Running SimpleCov](#running-simplecov)\n* [Usage](#usage)\n    * [Help commands](#help-commands)\n    * [Generate the SkunkCore for your project](#generate-the-skunkcore-for-your-project)\n    * [Comparing Feature Branches](#comparing-feature-branches)\n* [Sharing your SkunkScore](#sharing-your-skunkscore)\n* [Contributing](#contributing)\n* [Sponsorship](#sponsorship)\n\n## What is the SkunkScore?\n\nThe main goal of the SkunkScore is to serve as a compass in your next refactoring adventure. It will help you answer these questions:\n\n- What can I do to pay off technical debt?\n- What are the most complicated files with the least code coverage?\n- What are good candidates for my next test-writing efforts?\n- What are good candidates for my next refactoring efforts?\n\nTo assess the technical debt of a module, Skunk takes into account:\n- Code Complexity\n- Code Smells\n- Code Coverage\n\n## Getting started\n\nStart by including `skunk` in your Gemfile:\n\n```ruby\ngem 'skunk'\n```\n\nThen run `bundle`.\n\nOr, install it yourself by running: `$ gem install skunk`\n\n### Running SimpleCov to generate your Code Coverage report\nUse SimpleCov to generate a report of how many statements are covered by your test suite (code coverage). That's how `skunk` knows what's the status of your test suite + code coverage.\n\nPlease refer to [SimpleCov's Getting Started Guide](https://github.com/simplecov-ruby/simplecov#getting-started) to install it and generate the coverage report.\n\nSimpleCov was successfully installed when it generated a JSON file under `coverage/.resultset.json` in your application directory.\n\n\u003e :warning: Skunk runs `rubycritic`, which loads code coverage data from your `coverage/.resultset.json` file. Make sure to have this file for best SkunkScore results.\n\n**Note:** after adding more tests to your application, run SimpleCov again to generate an updated Code Coverage. This way, skunk will generate a new SkunkScore.\n## Usage\n\n### Help commands\n\nRun `skunk -h` to check out the help options:\n\n```\nUsage: skunk [options] [paths]\n    -b, --branch BRANCH              Set branch to compare\n    -o, --out FILE                   Output report to file\n    -v, --version                    Show gem's version\n    -h, --help                       Show this message\n```\n\n### Generating the SkunkCore for your project\n\nThe SkunkCore is a sorted list of smelly files. Skunk's report will be in the console. On the Ruby project you want to analyze, run:\n\n```\nskunk\n```\n\nThe result is a list of smelly files and the SkunkScore of the project/files:\n\n```\n+-----------------------------------------------------+----------------+------------------+--------------+--------------+--------------+\n| file                                                | skunk_score    | churn_times_cost | churn        | cost         | coverage     |\n+-----------------------------------------------------+----------------+------------------+--------------+--------------+--------------+\n| samples/rubycritic/analysed_module.rb               | 258.88         | 12.94            | 5            | 2.59         | 0.0          |\n| lib/skunk/commands/compare.rb                       | 85.41          | 32.32            | 14           | 2.31         | 63.64        |\n| lib/skunk/rubycritic/analysed_modules_collection.rb | 31.76          | 3.18             | 5            | 0.64         | 50.0         |\n| lib/skunk/commands/status_reporter.rb               | 11.33          | 68.0             | 18           | 3.78         | 97.5         |\n| lib/skunk/command_factory.rb                        | 8.3            | 1.95             | 4            | 0.49         | 83.33        |\n| lib/skunk/commands/status_sharer.rb                 | 8.17           | 10.9             | 4            | 2.72         | 97.67        |\n| lib/skunk/cli/application.rb                        | 7.06           | 21.19            | 18           | 1.18         | 94.12        |\n| lib/skunk/cli/options/argv.rb                       | 4.08           | 7.35             | 9            | 0.82         | 95.24        |\n| lib/skunk/commands/compare_score.rb                 | 3.77           | 2.51             | 4            | 0.63         | 94.74        |\n| lib/skunk/rubycritic/analysed_module.rb             | 3.37           | 33.74            | 10           | 3.37         | 100.0        |\n| lib/skunk/commands/version.rb                       | 2.64           | 0.7              | 8            | 0.09         | 70.0         |\n| lib/skunk/commands/output.rb                        | 1.86           | 0.09             | 1            | 0.09         | 80.0         |\n| lib/skunk/cli/options.rb                            | 0.68           | 5.44             | 8            | 0.68         | 100.0        |\n| lib/skunk/commands/default.rb                       | 0.4            | 3.23             | 8            | 0.4          | 100.0        |\n| lib/skunk/commands/shareable.rb                     | 0.2            | 0.4              | 2            | 0.2          | 100.0        |\n| lib/skunk/commands/help.rb                          | 0.2            | 1.2              | 6            | 0.2          | 100.0        |\n| lib/skunk/commands/base.rb                          | 0.1            | 0.49             | 5            | 0.1          | 100.0        |\n| lib/skunk.rb                                        | 0.0            | 0.0              | 6            | 0.0          | 100.0        |\n| lib/skunk/version.rb                                | 0.0            | 0.0              | 12           | 0.0          | 0.0          |\n+-----------------------------------------------------+----------------+------------------+--------------+--------------+--------------+\n\nSkunkScore Total: 428.21\nModules Analysed: 19\nSkunkScore Average: 22.54\nWorst SkunkScore: 258.88 (samples/rubycritic/analysed_module.rb)\n```\n\nWith the report, you can answer [these refactoring questions](#what-is-the-skunkscore) with clarity.\n\nIn this example, the file `samples/rubycritic/analysed_module.rb` has the Worst SkunkScore. It means this file has a high code complexity, with lower code coverage. To decrease its SkunkScore, start by adding tests to it. Then, simplify the code to decrease the code complexity.\n\nOther great candidates are the files that have lower code coverage. By adding tests, their SkunkScore will decrease, and refactoring the code will be more achievable.\n\nSkunk also gives you a SkunkScore Total value: it shows you the overall code quality of the project. As you decrease the SkunkScore of the files, the total score of the project will decrease.\n\n#### Excluding folders from the report\n\nTo only run skunk on specific folders, pass a list of directories in the command line. For example, if you only want the report for the files under `app` and `lib`, run:\n\n`skunk app lib`\n\n### Generate JSON report in background\n\nWhen the Skunk command is run, it will generate a JSON report file in the `RubyCritic::Config.root` location.\n\n### Comparing feature branches\n\nWhen working on new features, run skunk against your feature branch to check if the changes are improving or decreasing the code quality of the project.\n\nTo generate the SkunkScore of your feature branch, run:\n\n```\nskunk -b \u003cyour-feature-branch-name\u003e\n```\n\nThen, get a SkunkScore average comparison with `main` by running:\n\n`$ skunk -b main`\n\n```\nSwitched to branch 'main'\n....\n\nBase branch (main) average skunk score: 290.53999999999996\nFeature branch (feature/compare) average skunk score: 340.3005882352941\nScore: 340.3\n```\n\nThis should give you an idea if you're moving in the direction of maintaining the code quality or not. In this case, the feature branch is decreasing the code quality because it has a higher SkunkScore than the main branch.\n\n## Sharing your SkunkScore\n\nIf you want to share the results of your Skunk report with the Ruby community, run:\n\n`SHARE=true skunk app/`\n\n```\nSkunkScore Total: 126.99\nModules Analysed: 17\nSkunkScore Average: 7.47\nWorst SkunkScore: 41.92 (lib/skunk/commands/status_sharer.rb)\n\nGenerated with Skunk v0.5.0\nShared at: https://skunk.fastruby.io/\n```\n\nResults will be posted by default to https://skunk.fastruby.io which is a free and open source Ruby on Rails application sponsored by [OmbuLabs](https://www.ombulabs.com)([source code](https://github.com/fastruby/skunk.fyi)).\n\nIf you prefer to post results to your server, set your own `SHARE_URL`:\n\n`$ SHARE_URL=https://path.to.your.skunk-fyi-server.example.com skunk app/`\n\n```\nSkunkScore Total: 126.99\nModules Analysed: 17\nSkunkScore Average: 7.47\nWorst SkunkScore: 41.92 (lib/skunk/commands/status_sharer.rb)\n\nGenerated with Skunk v0.5.0\nShared at: https://path.to.your.skunk-fyi-server.example.com\n```\n\n## Contributing\nHave a fix for a problem you've been running into or an idea for a new feature you think would be useful? Want to see how you can support Skunk?\n\nTake a look at the [Contributing document](CONTRIBUTING.md) for instructions to set up the repo on your machine, check the Help Wanted section, and create a good Pull Request.\n\n## Sponsorship\n\n![FastRuby.io | Rails Upgrade Services](fastruby-logo.png)\n\n`skunk` is maintained and funded by [FastRuby.io](https://fastruby.io). The names and logos for FastRuby.io are trademarks of The Lean Software Boutique LLC.\n","funding_links":[],"categories":["Ruby","Programming Languages"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastruby%2Fskunk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastruby%2Fskunk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastruby%2Fskunk/lists"}