GithubHelp home page GithubHelp logo

fastruby / skunk Goto Github PK

View Code? Open in Web Editor NEW
502.0 10.0 25.0 285 KB

A SkunkScore Calculator for Ruby Code -- Find the most complicated code without test coverage!

Home Page: https://www.fastruby.io/blog/code-quality/intruducing-skunk-stink-score-calculator.html

License: MIT License

Ruby 99.64% Shell 0.36%
code-quality-analyzer code-quality code-coverage good-first-issue skunk-score hacktoberfest

skunk's People

Contributors

abizzinotto avatar bronzdoc avatar dependabot[bot] avatar etagwerker avatar fionadl avatar grzegorz-jakubiak avatar juanvqz avatar kindoflew avatar lubc avatar manuca avatar mateusdeap avatar matiasgarcia avatar olleolleolle avatar rdormer avatar sebastian-palma avatar stefannibrasil avatar themayurkumbhar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

skunk's Issues

[BUG] Error when running churn check

  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • I'm reporting the issue to the correct repository (for multi-repository projects)

Version, Branch, or Commit:

0.5.1

Expected behavior:

I expected to run skunk and see the skunk metrics.

Actual behavior:

It gets to the churn check and then outputs:

running churn
Stopped processing SimpleCov as a previous error not related to SimpleCov has been detected
Traceback (most recent call last):
	23: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/bin/ruby_executable_hooks:24:in `<main>'
	22: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/bin/ruby_executable_hooks:24:in `eval'
	21: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/bin/skunk:23:in `<main>'
	20: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/bin/skunk:23:in `load'
	19: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/skunk-0.5.1/exe/skunk:10:in `<top (required)>'
	18: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/skunk-0.5.1/lib/skunk/cli/application.rb:30:in `execute'
	17: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/skunk-0.5.1/lib/skunk/cli/commands/default.rb:33:in `execute'
	16: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/rubycritic-4.6.1/lib/rubycritic/commands/default.rb:24:in `critique'
	15: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/rubycritic-4.6.1/lib/rubycritic/analysers_runner.rb:29:in `run'
	14: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/rubycritic-4.6.1/lib/rubycritic/analysers_runner.rb:29:in `each'
	13: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/rubycritic-4.6.1/lib/rubycritic/analysers_runner.rb:32:in `block in run'
	12: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/rubycritic-4.6.1/lib/rubycritic/analysers/churn.rb:17:in `run'
	11: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/rubycritic-4.6.1/lib/rubycritic/core/analysed_modules_collection.rb:32:in `each'
	10: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/rubycritic-4.6.1/lib/rubycritic/core/analysed_modules_collection.rb:32:in `each'
	 9: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/rubycritic-4.6.1/lib/rubycritic/analysers/churn.rb:18:in `block in run'
	 8: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/rubycritic-4.6.1/lib/rubycritic/source_control_systems/git.rb:37:in `revisions_count'
	 7: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/rubycritic-4.6.1/lib/rubycritic/source_control_systems/git.rb:33:in `churn'
	 6: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/rubycritic-4.6.1/lib/rubycritic/source_control_systems/git.rb:33:in `new'
	 5: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/rubycritic-4.6.1/lib/rubycritic/source_control_systems/git/churn.rb:30:in `initialize'
	 4: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/rubycritic-4.6.1/lib/rubycritic/source_control_systems/git/churn.rb:48:in `call'
	 3: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/rubycritic-4.6.1/lib/rubycritic/source_control_systems/git/churn.rb:48:in `each'
	 2: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/rubycritic-4.6.1/lib/rubycritic/source_control_systems/git/churn.rb:48:in `block in call'
	 1: from /Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/rubycritic-4.6.1/lib/rubycritic/source_control_systems/git/churn.rb:61:in `process_line'
/Users/michaelhagar/.rvm/gems/ruby-2.7.2@sa/gems/rubycritic-4.6.1/lib/rubycritic/source_control_systems/git/churn.rb:69:in `process_date': wrong number of arguments (given 0, expected 1) (ArgumentError)

Steps to reproduce:

The repo I'm running it on is private so I can't share it.

Context and environment:

  1. Skunk 0.5.1
  2. Ruby 2.7.2

[BUG] Ruby 3.1.0 support

Bundler found conflicting requirements for the Ruby version:
In Gemfile:
Ruby (~> 3.1.0.0)

skunk (= 0.5.1) was resolved to 0.5.1, which depends on
  Ruby (< 3.1.0, >= 2.4.0)

[REQUEST] Skunk Score should be a "GPA score"-like letter based on a 0-100 scale

Before we start...:

  • I checked the documentation and didn't find this feature
  • I checked to make sure that this feature has not already been requested

Branch/Commit:

main branch.

Describe the feature:

As a new user
I want to run skunk
So that I can see a list of GPA scores per file

Problem:

As a new user
I run skunk
And then I see a list of skunk scores
And I don't understand if my app is in great shape or horrible shape

Current:

+-----------------------------------------------------+----------------------------+----------------------------+----------------------------+----------------------------+----------------------------+
| file                                                | skunk_score                | churn_times_cost           | churn                      | cost                       | coverage                   |
+-----------------------------------------------------+----------------------------+----------------------------+----------------------------+----------------------------+----------------------------+
| lib/skunk/cli/commands/default.rb                   | 166.44                     | 1.6643999999999999         | 3                          | 0.5548                     | 0                          |
| lib/skunk/cli/application.rb                        | 139.2                      | 1.392                      | 3                          | 0.46399999999999997        | 0                          |
| lib/skunk/cli/command_factory.rb                    | 97.6                       | 0.976                      | 2                          | 0.488                      | 0                          |
| test/test_helper.rb                                 | 75.2                       | 0.752                      | 2                          | 0.376                      | 0                          |
| lib/skunk/rubycritic/analysed_module.rb             | 48.12                      | 1.7184                     | 2                          | 0.8592                     | 72.72727272727273          |
| test/lib/skunk/cli/commands/status_reporter_test.rb | 45.6                       | 0.456                      | 1                          | 0.456                      | 0                          |
| lib/skunk/cli/commands/base.rb                      | 29.52                      | 0.2952                     | 3                          | 0.0984                     | 0                          |
| lib/skunk/cli/commands/status_reporter.rb           | 8.0                        | 7.9956                     | 3                          | 2.6652                     | 100.0                      |
| test/lib/skunk/rubycritic/analysed_module_test.rb   | 2.63                       | 2.6312                     | 2                          | 1.3156                     | 100.0                      |
| lib/skunk.rb                                        | 0.0                        | 0.0                        | 2                          | 0.0                        | 0                          |
| lib/skunk/cli/options.rb                            | 0.0                        | 0.0                        | 2                          | 0.0                        | 0                          |
| lib/skunk/version.rb                                | 0.0                        | 0.0                        | 2                          | 0.0                        | 0                          |
| lib/skunk/cli/commands/help.rb                      | 0.0                        | 0.0                        | 2                          | 0.0                        | 0                          |
+-----------------------------------------------------+----------------------------+----------------------------+----------------------------+----------------------------+----------------------------+

Proposed:

+-----------------------------------------------------+----------------------------+----------------------------+----------------------------+----------------------------+----------------------------+
| file                                                | skunk_score                | churn_times_cost           | churn                      | cost                       | coverage                   |
+-----------------------------------------------------+----------------------------+----------------------------+----------------------------+----------------------------+----------------------------+
| lib/skunk/cli/commands/default.rb                   | F (7/100)                     | 1.6643999999999999         | 3                          | 0.5548                     | 0                          |
| lib/skunk/cli/application.rb                        | D (47/100)                      | 1.392                      | 3                          | 0.46399999999999997        | 0                          |
| lib/skunk/cli/command_factory.rb                    | A (93/100)                       | 0.976                      | 2                          | 0.488                      | 0                          |

I will abide by the code of conduct

Add a simple way to share a skunk report by setting an environment variable (SHARE=true)

Before we start...:

  • I checked the documentation and didn't find this feature
  • I checked to make sure that this feature has not already been requested

Branch/Commit:

main branch

Problem:

There is no easy way to share Skunk reports with my team. I usually have to copy/paste data.

Solution:

As a developer using skunk
I want to share Skunk data using https://skunk.fastruby.io
So that I can quickly collaborate with my team

It could work like this:

SHARE=true bundle exec skunk
running flay smells

running flog smells
.............
running reek smells
.............
running complexity
.............
running attributes
.............
running churn
.............
running simple_cov
.............
New critique at file:////Users/etagwerker/Projects/fastruby/skunk/tmp/rubycritic/overview.html
...

SkunkScore Total: 612.31
Modules Analysed: 13
SkunkScore Average: 0.47100769230769230769230769231e2
Worst SkunkScore: 166.44 (lib/skunk/cli/commands/default.rb)
Shared at: https://skunk.fastruby.io/1335ce1

Mockups:

This is similar to the way that benchmark-ips works:

$ SHARE_URL=https://ips.fastruby.io ruby benchmarks/struct_vs_hash.rb
Ruby version: 2.6.3
Warming up --------------------------------------
              struct    29.961k i/100ms
                hash    28.806k i/100ms
Calculating -------------------------------------
              struct    302.729k (± 4.0%) i/s -      1.528M in   5.056211s
                hash    277.456k (± 3.9%) i/s -      1.411M in   5.095923s

Comparison:
              struct:   302728.7 i/s
                hash:   277456.0 i/s - 1.09x  (± 0.00) slower

Shared at: https://ips.fastruby.io/5

This is what it looks like for benchmark.fyi -> https://ips.fastruby.io/5

Resources:

There is already a skunk.fyi project: https://github.com/fastruby/skunk.fyi

It is currently running here: https://skunk.fastruby.io

[REQUEST] Add support for branch comparison when code coverage has changed between branches

Before we start...:

  • I checked the documentation and didn't find this feature
  • I checked to make sure that this feature has not already been requested

Branch/Commit:

main branch

Problem:

When using the -b option, the SkunkScore average doesn't change if you improve code coverage for your application/library.

Solution:

As a developer using skunk -b stable-branch
I want to see the right SkunkScore delta
So that I can quickly see how much I've improved my project by paying off tech debt

It could work like this:

skunk -b main
Switched to branch 'main'
running flay smells
...
running flog smells
.......................
running reek smells
.......................
running complexity
.......................
running attributes
.......................
running churn
.......................
running simple_cov
.......................
Switched to branch 'poc/compare-issue'
running flay smells
...
running flog smells
.......................
running reek smells
.......................
running complexity
.......................
running attributes
.......................
running churn
.......................
running simple_cov
.......................
Base branch (main) average skunk score: 32.21
Feature branch (poc/compare-issue) average skunk score: 27.21
**Code coverage average improved by 7.27%**
**Skunk score average is 15% better** 

Notes:

It might be necessary to run the entire test suite "all over again" for one of the branches, so that we can compare two different result sets from SimpleCov.

I imagine it could work like this:

  1. Save a copy of the files for the current branch's coverage directory in a .skunk local directory
  2. Run all calculations for the current branch
  3. Switch to the "compared branch"
  4. Run the entire test suite using COVERAGE=true
  5. Save a copy of the files for the "compared branch" directory in a .skunk local directory
  6. Compare all results
  7. Output delta information

[BUG] skunk_score method documentation is inaccurate

Before we start...:

  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • I'm reporting the issue to the correct repository (for multi-repository projects)

Version, Branch, or Commit:

main branch.

Expected behavior:

https://rubydoc.info/github/fastruby/skunk/main/RubyCritic%2FAnalysedModule:skunk_score should document the method properly.

Actual behavior:

https://rubydoc.info/github/fastruby/skunk/main/RubyCritic%2FAnalysedModule:skunk_score mentions churn_times_cost but skunk_score does not really use churn as an input.

Steps to reproduce:

Method documentation:

Screen Shot 2022-11-15 at 11 04 15 AM

Method source code:

https://github.com/fastruby/skunk/blob/main/lib/skunk/rubycritic/analysed_module.rb#L33-L37

I will abide by the [code of conduct] (https://github.com/fastruby/skunk/blob/master/CODE_OF_CONDUCT.md)

Output to file

It would be awesome if, instead of sending the output to STDOUT the result could be stored in a file.

[BUG] Skunk has Ruby requirement < 3.1.0 which won't work when using Ruby 3.1.2

When trying to bundle skunk in an app using Ruby 3.1.2, I get this error:

Bundler found conflicting requirements for the Ruby version:
  In Gemfile:
    Ruby (~> 3.1.2.0)

    skunk was resolved to 0.5.1, which depends on
      Ruby (< 3.1.0, >= 2.4.0)

Bundler could not find compatible versions for gem "parser":
  In snapshot (Gemfile.lock):
    parser (= 3.1.2.0)

  In Gemfile:
    rubocop-performance was resolved to 1.13.3, which depends on
      rubocop (>= 1.7.0, < 2.0) was resolved to 1.28.2, which depends on
        parser (>= 3.1.0.0)

    skunk was resolved to 0.3.0, which depends on
      rubycritic (~> 4.2.1) was resolved to 4.2.2, which depends on
        parser (~> 2.6.0)

[0.4.2] undefined local variable or method `coverage` for RubyCritic::AnalysedModule

Hi!

I wanted to try out skunk in my project and it's breaking.

Before running it, I ran my test suite with simplecov and I have the coverage/.resultset.json in my project folder.

When running skunk, I get this:

Traceback (most recent call last):
  15: from /home/matias/.rvm/gems/ruby-2.5.7@foo/bin/ruby_executable_hooks:24:in `<main>'
	14: from /home/matias/.rvm/gems/ruby-2.5.7@foo/bin/ruby_executable_hooks:24:in `eval'
	13: from /home/matias/.rvm/gems/ruby-2.5.7@foo/bin/skunk:23:in `<main>'
12: from /home/matias/.rvm/gems/ruby-2.5.7@foo/bin/skunk:23:in `load'
	11: from /home/matias/.rvm/gems/ruby-2.5.7@foo/gems/skunk-0.4.2/exe/skunk:10:in `<top (required)>'
	10: from /home/matias/.rvm/gems/ruby-2.5.7@foo/gems/skunk-0.4.2/lib/skunk/cli/application.rb:21:in `execute'
9: from /home/matias/.rvm/gems/ruby-2.5.7@foo/gems/skunk-0.4.2/lib/skunk/cli/commands/default.rb:25:in `execute'
	 8: from /home/matias/.rvm/gems/ruby-2.5.7@foo/gems/skunk-0.4.2/lib/skunk/cli/commands/default.rb:31:in `report'
	 7: from /home/matias/.rvm/gems/ruby-2.5.7@foo/gems/rubycritic-4.1.0/lib/rubycritic/commands/status_reporter.rb:17:in `score='
6: from /home/matias/.rvm/gems/ruby-2.5.7@foo/gems/rubycritic-4.1.0/lib/rubycritic/commands/status_reporter.rb:24:in `update_status'
	 5: from /home/matias/.rvm/gems/ruby-2.5.7@foo/gems/skunk-0.4.2/lib/skunk/cli/commands/status_reporter.rb:29:in `update_status_message'
	 4: from /home/matias/.rvm/gems/ruby-2.5.7@foo/gems/skunk-0.4.2/lib/skunk/cli/commands/status_reporter.rb:71:in `table_options'
3: from /home/matias/.rvm/gems/ruby-2.5.7@foo/gems/skunk-0.4.2/lib/skunk/cli/commands/status_reporter.rb:53:in `sorted_modules'
	 2: from /home/matias/.rvm/gems/ruby-2.5.7@foo/gems/skunk-0.4.2/lib/skunk/cli/commands/status_reporter.rb:53:in `sort_by'
	 1: from /home/matias/.rvm/gems/ruby-2.5.7@foo/gems/skunk-0.4.2/lib/skunk/cli/commands/status_reporter.rb:53:in `each'
/home/matias/.rvm/gems/ruby-2.5.7@foo/gems/skunk-0.4.2/lib/skunk/rubycritic/analysed_module.rb:34:in `stink_score': undefined local variable or method `coverage' for #<RubyCritic::AnalysedModule:0x00005635e358e9d0> (NameError)

This is the Gemfile.lock

    skunk (0.4.2)
      rubycritic (~> 4.0)
      terminal-table (~> 1.8.0)
    rubycritic (4.1.0)
      flay (~> 2.8)
      flog (~> 4.4)
      launchy (= 2.4.3)
      parser (~> 2.6.0)
      rainbow (~> 3.0)
      reek (~> 5.0, < 6.0)
      ruby_parser (~> 3.8)
      tty-which (~> 0.4.0)
      virtus (~> 1.0)

I realized that you are monkey patching RubyCritic::AnalysedModule and relying on the coverage method that, at least on 4.1.0 isn't available.


After some digging, I realized that you made a fix in the RubyCritic library for 4.2.0 so I guess the fix for this would be bumping the requirement to at least that version unless I am missing something.

When noticing that, I made a fork to update the requirements and that's when I realized that I was forced to upgrade my project to simplecov 0.18, which seems to break the gem according to this so I am a bit lost figuring out the proper fix.

Thanks!

Add a SkunkScore for dependencies

The complexity and smell of an application is not just limited to just the project's code. It also includes all the dependencies of that code.

Ideally, there should be a separate score for dependencies so that developers can see which ones they should either eliminate, bring into their own codebase, or (in the case of opensource dependencies) help the maintainers improve those libraries.

stink_score should not include churn in its math

I think there is a problem when evaluating this scenario:

  • foo.rb: churn (1); cost (100); coverage (100) -- then the stink score is 100 (1*100) which is churn * cost * no penalty factor

If I make a change to improve the file and reduce the cost by 20%, then I end up with this:

  • foo.rb: churn (2); cost (80); coverage (100) -- then the stink score is 160 (2*80) which is a shame, because the developer worked on reducing tech debt but they ended up with a worse stink score

I think that removing the churn from the stink score formula should solve this problem

Add ability to sort output results

IMPORTANT: please make sure you ask yourself all intro questions and fill all sections of the template.

Before we start...:

  • I checked the documentation and didn't find this feature
  • I checked to make sure that this feature has not already been requested

Branch/Commit:

Inform what branch/commit/version of "Skunk" you are using.

77bbd4e

Describe the feature:

Please include a detailed description of the feature you are requesting and any details on it’s expected behavior.

As an end user of skunk
I generate a skunk report for an application
And I see a skunk report sorted in ascending order of skunk scores

Problem:

Please include a detailed description of the problem this feature would solve.

As an end user of skunk
I want to generate a skunk report in a different order, say in ascending order of churn_times_cost values
So that I can a analyze my application from different perspectives and emphasizing different metrics

I will abide by the code of conduct

Add support for SimpleCov > 0.18.x

Right now skunk is not compatible with the latest release of SimpleCov -- more here: simplecov-ruby/simplecov#887

We should follow this path:

You will get unexpected results if you're trying to use a coverage/.resultset.json file generated with SimpleCov v0.18.x or higher.

Skunk breaks when is using simplecov 0.21.2

When I run skunk app using skunk 0.5.1 and simplecov 0.21.2 is activated I get the following error:

Traceback (most recent call last):
        17: from /Users/bronzdoc/.rbenv/versions/2.7.1/bin/skunk:23:in `<main>'
        16: from /Users/bronzdoc/.rbenv/versions/2.7.1/bin/skunk:23:in `load'
        15: from /Users/bronzdoc/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/skunk-0.5.0/exe/skunk:10:in `<top (required)>'
        14: from /Users/bronzdoc/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/skunk-0.5.0/lib/skunk/cli/application.rb:30:in `execute'
        13: from /Users/bronzdoc/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/skunk-0.5.0/lib/skunk/cli/commands/default.rb:30:in `execute'
        12: from /Users/bronzdoc/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubycritic-4.5.2/lib/rubycritic/commands/default.rb:24:in `critique'
        11: from /Users/bronzdoc/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubycritic-4.5.2/lib/rubycritic/analysers_runner.rb:29:in `run'
        10: from /Users/bronzdoc/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubycritic-4.5.2/lib/rubycritic/analysers_runner.rb:29:in `each'
         9: from /Users/bronzdoc/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubycritic-4.5.2/lib/rubycritic/analysers_runner.rb:32:in `block in run'
         8: from /Users/bronzdoc/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubycritic-4.5.2/lib/rubycritic/analysers/coverage.rb:18:in `run'
         7: from /Users/bronzdoc/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubycritic-4.5.2/lib/rubycritic/core/analysed_modules_collection.rb:32:in `each'
         6: from /Users/bronzdoc/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubycritic-4.5.2/lib/rubycritic/core/analysed_modules_collection.rb:32:in `each'
         5: from /Users/bronzdoc/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubycritic-4.5.2/lib/rubycritic/analysers/coverage.rb:19:in `block in run'
         4: from /Users/bronzdoc/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubycritic-4.5.2/lib/rubycritic/analysers/coverage.rb:36:in `find_coverage_percentage'
         3: from /Users/bronzdoc/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/simplecov-0.21.2/lib/simplecov/source_file.rb:81:in `covered_percent'
         2: from /Users/bronzdoc/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/simplecov-0.21.2/lib/simplecov/source_file.rb:35:in `coverage_statistics'
         1: from /Users/bronzdoc/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/simplecov-0.21.2/lib/simplecov/source_file.rb:337:in `line_coverage_statistics'
/Users/bronzdoc/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/simplecov-0.21.2/lib/simplecov/source_file.rb:245:in `lines_strength': undefined method `map' for nil:NilClass (NoMethodError)

Uninstalling simplecov 0.21.2 and falling back to 0.19.0 makes it work

SkunkScore Total: 507726.42
Modules Analysed: 1266
SkunkScore Average: 401.05
Worst SkunkScore: 9749.88 (app/controllers/user_site/stop_payment_requests_controller.rb)

Generated with Skunk v0.5.1

I will abide by the [code of conduct] (https://github.com/fastruby/skunk/blob/master/CODE_OF_CONDUCT.md)

Configuration file with list of ignored files

It would be nice not to see files from e.g. db/migrate/ inside my Skunk summary output. These files need to exist in a codebase but do not carry any meaningful weight when it comes to that codebase's maintainability. Do you think it could be useful to add a configuration file where file globs could be provided for files to ignore? Rubocop etc. definitely provide some prior art that could be copied here.

Print a warning when running `skunk` without a `coverage/.resultset.json`

In the README.md:

To get the best results, make sure that you have coverage/.resultset.json in
your application directory. That way skunk knows what's the status of your
test suite + code coverage.

Running skunk without that file is kind of pointless. The whole idea of the "StinkScore" is to combine RubyCritic's cost with SimpleCov's lack of coverage, in order to get a realistic "StinkScore"

So we should make sure the user understands that the scores that they're getting is not that useful.

[BUG] Nested /test or /spec folders are not ignored

IMPORTANT: please make sure you ask yourself all intro questions and fill all sections of the template.

Before we start...:

  • I checked the documentation and didn't find this feature
  • I checked to make sure that this feature has not already been requested

Branch/Commit:

Main branch.

Describe the feature:

As a User
When I run skunk on a directory that has nested /spec or /test folders
Then I don't see reports for files inside nested /spec or /test folders

Problem:
Currenty, we are ignoring folders that starts with test or spec

a_module.pathname.to_s.start_with?("test", "spec")
but we are not ignoring folders that are nested like engines/my_engine/spec/.

This makes skunk to report those files as 0% test coverage and really high skunk scores.

I will abide by the code of conduct

execute ': undefined method `share'

When I try to execute skunk -v to see the version of skunk I'm getting the following error:

0.5.1
Traceback (most recent call last):
        3: from /Users/bronzdoc/.rbenv/versions/2.7.1/bin/skunk:23:in `<main>'
        2: from /Users/bronzdoc/.rbenv/versions/2.7.1/bin/skunk:23:in `load'
        1: from /Users/bronzdoc/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/skunk-0.5.1/exe/skunk:10:in `<top (required)>'
/Users/bronzdoc/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/skunk-0.5.1/lib/skunk/cli/application.rb:33:in `execute': undefined method `share' for #<Skunk::Command::Version:0x00007f894006e070> (NoMethodError)

Skunk version: 0.5.1
Ruby version: 2.7.1

I will abide by the [code of conduct] (https://github.com/fastruby/skunk/blob/master/CODE_OF_CONDUCT.md)

test suite should not depend on project's own git history

Every time I commit anything to the library's repository, the tests start to fail. 🤦‍♂

That is because the StinkScore in the test suite depends� on the library's churn, which is not cool.


  1) Failure:
Skunk::Command::StatusReporter::#update_status_message#test_0001_reports the StinkScore [/Users/etagwerker/Projects/fastruby/skunk/test/lib/skunk/cli/commands/status_reporter_test.rb:26]:
--- expected
+++ actual
@@ -1,11 +1,11 @@
 "+-----------------------------------------+-------------------------------+-------------------------------+------------------------------+------------------------------+------------------------------+
 | file                                    | stink_score                   | churn_times_cost              | churn                        | cost                         | coverage                     |
 +-----------------------------------------+-------------------------------+-------------------------------+------------------------------+------------------------------+------------------------------+
-| lib/skunk/rubycritic/analysed_module.rb | 24.06                         | 0.8592                        | 1                            | 0.8592                       | 72.72727272727273            |
+| lib/skunk/rubycritic/analysed_module.rb | 48.12                         | 1.7184                        | 2                            | 0.8592                       | 72.72727272727273            |
 +-----------------------------------------+-------------------------------+-------------------------------+------------------------------+------------------------------+------------------------------+

-StinkScore Total: 24.06
+StinkScore Total: 48.12
 Modules Analysed: 1
-StinkScore Average: 0.2406e2
-Worst StinkScore: 24.06 (lib/skunk/rubycritic/analysed_module.rb)
+StinkScore Average: 0.4812e2
+Worst StinkScore: 48.12 (lib/skunk/rubycritic/analysed_module.rb)
 "



  2) Failure:
RubyCritic::AnalysedModule::#stink_score::when there is perfect code coverage#test_0001_should not be penalized [/Users/etagwerker/Projects/fastruby/skunk/test/lib/skunk/rubycritic/analysed_module_test.rb:47]:
Expected: 0.86
  Actual: 1.72


  3) Failure:
RubyCritic::AnalysedModule::#stink_score::when there is no test coverage#test_0001_should be 99.32 [/Users/etagwerker/Projects/fastruby/skunk/test/lib/skunk/rubycritic/analysed_module_test.rb:31]:
Expected: 85.92
  Actual: 171.84


  4) Failure:
RubyCritic::AnalysedModule::#stink_score::when there is near-perfect code coverage#test_0001_should be penalized slightly [/Users/etagwerker/Projects/fastruby/skunk/test/lib/skunk/rubycritic/analysed_module_test.rb:39]:
Expected: 4.3
  Actual: 8.59

4 runs, 4 assertions, 4 failures, 0 errors, 0 skips
rake aborted!
Command failed with status (1): [ruby -I"lib:lib:test" -I"/Users/etagwerker/.rvm/gems/ruby-2.6.2@skunk/gems/rake-10.5.0/lib" "/Users/etagwerker/.rvm/gems/ruby-2.6.2@skunk/gems/rake-10.5.0/lib/rake/rake_test_loader.rb" "test/**/*_test.rb" ]
/Users/etagwerker/.rvm/gems/ruby-2.6.2@skunk/bin/ruby_executable_hooks:24:in `eval'
/Users/etagwerker/.rvm/gems/ruby-2.6.2@skunk/bin/ruby_executable_hooks:24:in `<main>'
Tasks: TOP => default => test
(See full trace by running task with --trace)

We should have a directory inside test/samples that has all the data we need for the test suite to work always :)

[BUG] When comparing with other branches, output file is blank

Before we start...:

  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • I'm reporting the issue to the correct repository (for multi-repository projects)

Version, Branch, or Commit:

0.5.2

Expected behavior:

Expected to compare skunk score between branches, and output the result to a desired file.

Actual behavior:

Skunk analysis runs well on shell with desired results, but the output file is blank.

Steps to reproduce:

From a feature branch:

skunk -b main -o skunk.txt

Context and environment:

  • Operating System: Mac OS
  • Operating System version: 12.2.1 (21D62)
  • Ruby version: 2.7.3p183

I will abide by the [code of conduct] (https://github.com/fastruby/skunk/blob/master/CODE_OF_CONDUCT.md)

Specify Ruby versions supported by Skunk

Using ruby 1.8.7 😬

gem install skunk
Fetching: sexp_processor-4.14.1.gem (100%)
ERROR:  Error installing skunk:
        sexp_processor requires Ruby version ~> 2.2.
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.30
  - RUBY VERSION: 1.8.7 (2012-06-29 patchlevel 370) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /usr/local/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/local/lib/ruby/gems/1.8
     - /root/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

Keep track of SkunkScore average over time

It would be awesome if we can keep track of the StinkScore average score over time.

That way you can know whether your changes are improving the situation or making it worse.

When running `skunk -b master` I get a ENOENT error

I just tried to run skunk -b master using skunk v0.3.0 and I found this issue:

Traceback (most recent call last):
	11: from /Users/etagwerker/.rvm/gems/ruby-2.6.3/bin/ruby_executable_hooks:24:in `<main>'
	10: from /Users/etagwerker/.rvm/gems/ruby-2.6.3/bin/ruby_executable_hooks:24:in `eval'
	 9: from /Users/etagwerker/.rvm/gems/ruby-2.6.3/bin/skunk:23:in `<main>'
	 8: from /Users/etagwerker/.rvm/gems/ruby-2.6.3/bin/skunk:23:in `load'
	 7: from /Users/etagwerker/.rvm/gems/ruby-2.6.3/gems/skunk-0.3.0/exe/skunk:10:in `<top (required)>'
	 6: from /Users/etagwerker/.rvm/gems/ruby-2.6.3/gems/skunk-0.3.0/lib/skunk/cli/application.rb:16:in `execute'
	 5: from /Users/etagwerker/Projects/fastruby/rubycritic/lib/rubycritic/commands/compare.rb:20:in `execute'
	 4: from /Users/etagwerker/Projects/fastruby/rubycritic/lib/rubycritic/commands/compare.rb:38:in `compare_branches'
	 3: from /Users/etagwerker/Projects/fastruby/rubycritic/lib/rubycritic/commands/compare.rb:65:in `compare_code_quality'
	 2: from /Users/etagwerker/.rvm/gems/ruby-2.6.3/gems/skunk-0.3.0/lib/skunk/cli/commands/compare.rb:35:in `build_details'
	 1: from /Users/etagwerker/.rvm/gems/ruby-2.6.3/gems/skunk-0.3.0/lib/skunk/cli/commands/compare.rb:35:in `open'
/Users/etagwerker/.rvm/gems/ruby-2.6.3/gems/skunk-0.3.0/lib/skunk/cli/commands/compare.rb:35:in `initialize': No such file or directory @ rb_sysopen - /Users/etagwerker/Projects/fastruby/rubycritic/tmp/rubycritic/compare/build_details.txt (Errno::ENOENT)

It seems that it is expecting a compare directory to be there but it is not.

A workaround to solve this problem is to do this:

$ mkdir tmp/rubycritic/compare

Then skunk -b master seems to work fine.

RFC: Formula needs attention (churn * cost * penalty produces unexpected results)

Context

Initially the SkunkScore was calculated as churn * cost * penalty. This made sense based on the churn vs. complexity idea -> https://www.agileconnection.com/article/getting-empirical-about-refactoring

However, I quickly realized that this formula would not work when running skunk -b master -- more here: https://www.fastruby.io/blog/code-quality/escaping-the-tar-pit-at-rubyconf.html

So I decided to change the formula to be cost * penalty.

Alternatives

I think a potential solution is to apply a modified weight to churn, so that the formula could look like this:

skunk_score = (magical_weight * churn) * cost * penalty_factor

That way, the formula could work both as a snapshot and as a comparison between two branches.

Test

Testing this should show that removing complexity in a module, git committing, and then running skunk -b master produces a lower skunk score.

[BUG] Compare command is now raising an error on v0.5.0 (related to the share feature)

Before we start...:

  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • I'm reporting the issue to the correct repository (for multi-repository projects)

Version, Branch, or Commit:

Skunk v0.5.0

Expected behavior:

Calling a compare command with SHARE=true should just work

Actual behavior:

Calling a compare command with SHARE=true does not work

Steps to reproduce:

From a feature branch:

skunk -b main

That should reproduce the error.

Context and environment:

All environments. Reproduced on GitHub Actions and Mac OS X.

Logs

Here is a backtrace from skunk.fyi:

skunk -b main
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
warning: Couldn't find coverage info at coverage/.resultset.json.
warning: Having no coverage metrics will make your SkunkScore worse.
Switched to branch 'main'
running flay smells

running flog smells
.......................................
running reek smells
.......................................
running complexity
.......................................
running attributes
.......................................
running churn
.......................................
running simple_cov
.......................................
Switched to branch 'feature/issue-templates'
running flay smells

running flog smells
.......................................
running reek smells
.......................................
running complexity
.......................................
running attributes
.......................................
running churn
.......................................
running simple_cov
.......................................
Base branch (main) average skunk score: 19.02
Feature branch (feature/issue-templates) average skunk score: 19.02
Skunk score average is 0% better
Score: 19.02
Traceback (most recent call last):
	5: from /Users/etagwerker/.rvm/gems/ruby-2.7.2@skunk-fyi/bin/ruby_executable_hooks:24:in `<main>'
	4: from /Users/etagwerker/.rvm/gems/ruby-2.7.2@skunk-fyi/bin/ruby_executable_hooks:24:in `eval'
	3: from /Users/etagwerker/.rvm/gems/ruby-2.7.2@skunk-fyi/bin/skunk:23:in `<main>'
	2: from /Users/etagwerker/.rvm/gems/ruby-2.7.2@skunk-fyi/bin/skunk:23:in `load'
	1: from /Users/etagwerker/.rvm/gems/ruby-2.7.2@skunk-fyi/gems/skunk-0.5.0/exe/skunk:10:in `<top (required)>'
/Users/etagwerker/.rvm/gems/ruby-2.7.2@skunk-fyi/gems/skunk-0.5.0/lib/skunk/cli/application.rb:33:in `execute': undefined method `share' for #<Skunk::Command::Compare:0x00007fd35103b200> (NoMethodError)

Source: https://github.com/fastruby/skunk.fyi/runs/1874192351?check_suite_focus=true

I will abide by the [code of conduct] (https://github.com/fastruby/skunk/blob/master/CODE_OF_CONDUCT.md)

[REQUEST] Improve comparison interface to output improvement (or not) related to the changes in the branch

Before we start...:

  • I checked the documentation and didn't find this feature
  • I checked to make sure that this feature has not already been requested

Branch/Commit:

main branch.

Problem:

As a developer
*I want to compare my branch vs main branch
So that I can understand/share how much tech debt I paid off or added with my changes

Mockups:

It could work like this:

skunk -b main
Switched to branch 'main'
running flay smells
...
running flog smells
.......................
running reek smells
.......................
running complexity
.......................
running attributes
.......................
running churn
.......................
running simple_cov
.......................
Switched to branch 'poc/compare-issue'
running flay smells
...
running flog smells
.......................
running reek smells
.......................
running complexity
.......................
running attributes
.......................
running churn
.......................
running simple_cov
.......................
Base branch (main) average skunk score: 32.21
Feature branch (poc/compare-issue) average skunk score: 27.21
**Skunk score average is 15% better** 

Resources:

See this section: https://github.com/fastruby/skunk#comparing-one-branch-vs-another

[REQUEST] Ruby versions compatibility

Describe the feature:

As a User
I want to see which version of Skunk I can use for my Ruby version

Problem:

The Ruby version requirement for Skunk at ruby gems is not accurate for older versions at least.

https://rubygems.org/gems/skunk/versions/0.4.2 says Ruby >= 0, but that version depends on reek 5.4.0 which depends on Ruby >= 2.3.0.

Maybe a table of which version of skunk is recommended for each version of ruby is useful.

I will abide by the code of conduct

Feature request: Add command to compare stink score between one branch and another

It would be great if we can tell how much our changes are improving the stink score. It's pretty common to open a branch from master, make your changes, then submit them to be merged.

Just like RubyCritic allows you to pass a -b <branch-name> parameter, to compare code between your branch and another, it would be cool if skunk accepted a similar parameter.

As a developer who is making changes to reduce technical debt, I want to call skunk -b master to compare my current branch's stink score vs. master's stink score.

Table width exceeds wanted width...

Read your blog and thought to give it a try. Love the concept!

Ran into this when output was generated:

../gems/terminal-table-1.8.0/lib/terminal-table/table.rb:305:in `recalc_column_widths': Table width exceeds wanted width of 200 characters. (RuntimeError)

Thoughts on toggling the settings within the skunk command? skunk --width=400?

Output is no longer accurate

Output in the README is incorrect:

New critique at file:////Users/etagwerker/Projects/fastruby/skunk/tmp/rubycritic/overview.html
+-----------------------------------------------------+----------------------------+----------------------------+----------------------------+----------------------------+----------------------------+
| file                                                | stink_score                | churn_times_cost           | churn                      | cost                       | coverage                   |
+-----------------------------------------------------+----------------------------+----------------------------+----------------------------+----------------------------+----------------------------+
| lib/skunk/cli/commands/default.rb                   | 166.44                     | 1.6643999999999999         | 3                          | 0.5548                     | 0                          |
| lib/skunk/cli/application.rb                        | 139.2                      | 1.392                      | 3                          | 0.46399999999999997        | 0                          |
| lib/skunk/cli/command_factory.rb                    | 97.6                       | 0.976                      | 2                          | 0.488                      | 0                          |
| test/test_helper.rb                                 | 75.2                       | 0.752                      | 2                          | 0.376                      | 0                          |
| lib/skunk/rubycritic/analysed_module.rb             | 48.12                      | 1.7184                     | 2                          | 0.8592                     | 72.72727272727273          |
| test/lib/skunk/cli/commands/status_reporter_test.rb | 45.6                       | 0.456                      | 1                          | 0.456                      | 0                          |
| lib/skunk/cli/commands/base.rb                      | 29.52                      | 0.2952                     | 3                          | 0.0984                     | 0                          |
| lib/skunk/cli/commands/status_reporter.rb           | 8.0                        | 7.9956                     | 3                          | 2.6652                     | 100.0                      |
| test/lib/skunk/rubycritic/analysed_module_test.rb   | 2.63                       | 2.6312                     | 2                          | 1.3156                     | 100.0                      |
| lib/skunk.rb                                        | 0.0                        | 0.0                        | 2                          | 0.0                        | 0                          |
| lib/skunk/cli/options.rb                            | 0.0                        | 0.0                        | 2                          | 0.0                        | 0                          |
| lib/skunk/version.rb                                | 0.0                        | 0.0                        | 2                          | 0.0                        | 0                          |
| lib/skunk/cli/commands/help.rb                      | 0.0                        | 0.0                        | 2                          | 0.0                        | 0                          |
+-----------------------------------------------------+----------------------------+----------------------------+----------------------------+----------------------------+----------------------------+

We are no longer displaying churn times cost.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.