Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve formatting for steep stats #300

Closed
rramsden opened this issue Jan 20, 2021 · 6 comments · Fixed by #360
Closed

Improve formatting for steep stats #300

rramsden opened this issue Jan 20, 2021 · 6 comments · Fixed by #360

Comments

@rramsden
Copy link

Just a suggestion, feel free to close this.

Would be great to format the results of steep stats into something more human readable.

On the evilmartian blog post on RBS and Steep this was also a surprise to the author that the output was in CSV format.

Something more like the following would be great (author ended up using awk to format the results):

$ bundle exec steep stats --log-level=fatal | awk -F',' '{ printf "%-28s %-9s %-12s %-14s %-10s\n", $2, $3, $4, $5, $7 }'
File                         Status    Typed calls  Untyped calls  Typed %
lib/rubanok/dsl/mapping.rb   success   7            2              63.64
lib/rubanok/dsl/matching.rb  success   26           18             52.00
lib/rubanok/processor.rb     success   34           8              69.39
lib/rubanok/rule.rb          success   24           12             66.67
lib/rubanok/version.rb       success   0            0              0
lib/rubanok.rb               success   8            4              66.67

Maybe something like the following:

steep stats --format=[pretty,json,csv]

Where pretty is formatted table output like above. It should also be the default formatter and multiple formats can be supported by using --format= option.

I'm happy to work on something like this if we can agree on what it would look like.

What does everyone think?

Thanks

@ybiquitous
Copy link
Contributor

Hi @rramsden, I use the following custom rake task:

namespace :steep do
  desc "Show the Steep coverage report"
  task :stats do
    sh "bundle exec steep stats --log-level=fatal | column -s, -t | sort --key=7 --sort=numeric"
  end
end

image

I think it most flexible to use existing UNIX commands.

@soutaro
Copy link
Owner

soutaro commented Feb 1, 2021

Hi @rramsden,

I was assuming that we can use column command, but I can agree that built-in pretty formatting is better.

It is almost just because I don't want to implement the column printing function. Do you know any good gem to do it?

@palkan
Copy link
Sponsor

palkan commented Mar 5, 2021

Hey everyone!

Do you know any good gem to do it?

I've been using these two: https://github.com/tj/terminal-table and https://github.com/piotrmurach/tty-table.
The former has zero dependencies but the latter one is more powerful (and terminal-focused).

@soutaro soutaro linked a pull request Mar 27, 2021 that will close this issue
@soutaro
Copy link
Owner

soutaro commented Mar 27, 2021

@rramsden, @ybiquitous, @palkan,

Finally implemented with terminal-table gem in #360. Any feedback is welcome!

@ybiquitous
Copy link
Contributor

@soutaro Great! I think it is what we want.

Thanks to #360, the hack using | column will be needless.
For your reference, here is an output result from my project. It's nice. 😄 👍

bundle exec steep stats --log-level=fatal --format=table
 Target  File                                             Status   Typed calls  Untyped calls  All calls  Typed %
------------------------------------------------------------------------------------------------------------------
 lib     lib/runners.rb                                   success          109              0        109     100%
 lib     lib/runners/analyzer.rb                          success           18              3         21      85%
 lib     lib/runners/analyzers.rb                         success           35              3         38      92%
 lib     lib/runners/changes.rb                           success           58              2         60      96%
 lib     lib/runners/cli.rb                               success          114              6        123      92%
 lib     lib/runners/command.rb                           success            4              0          4     100%
 lib     lib/runners/config.rb                            success          103             16        119      86%
 lib     lib/runners/config_generator.rb                  success           19              1         20      95%
 lib     lib/runners/cplusplus.rb                         success           50              2         53      94%
 lib     lib/runners/errors.rb                            success            0              0          0     100%
 lib     lib/runners/git_blame_info.rb                    success           35              6         41      85%
 lib     lib/runners/go.rb                                success            1              0          1     100%
 lib     lib/runners/harness.rb                           success           97             24        121      80%
 lib     lib/runners/ignoring.rb                          success           16              0         16     100%
 lib     lib/runners/io.rb                                success           11              0         11     100%
 lib     lib/runners/io/aws_s3.rb                         success           41              0         41     100%
 lib     lib/runners/issue.rb                             success           62             17         80      77%
 lib     lib/runners/java.rb                              success           57              0         57     100%
 lib     lib/runners/kotlin.rb                            success            0              0          0     100%
 lib     lib/runners/location.rb                          success           42             10         52      80%
 lib     lib/runners/nodejs.rb                            success          124              7        131      94%
 lib     lib/runners/options.rb                           success           25              5         30      83%
 lib     lib/runners/php.rb                               success            3              0          3     100%
 lib     lib/runners/processor.rb                         success          174             11        187      93%
 lib     lib/runners/processor/brakeman.rb                success           51             14         65      78%
 lib     lib/runners/processor/checkstyle.rb              success          134              2        136      98%
 lib     lib/runners/processor/clang_tidy.rb              success           50              1         51      98%
 lib     lib/runners/processor/code_sniffer.rb            success           85             20        105      80%
 lib     lib/runners/processor/coffeelint.rb              success           40             14         54      74%
 lib     lib/runners/processor/cppcheck.rb                success          129             10        139      92%
 lib     lib/runners/processor/cpplint.rb                 success           88             13        101      87%
 lib     lib/runners/processor/detekt.rb                  success           97              2         99      97%
 lib     lib/runners/processor/eslint.rb                  success          123             16        139      88%
 lib     lib/runners/processor/flake8.rb                  success           63              2         65      96%
 lib     lib/runners/processor/fxcop.rb                   success           38             17         55      69%
 lib     lib/runners/processor/golangci_lint.rb           success          144             25        169      85%
 lib     lib/runners/processor/goodcheck.rb               success           82             18        100      82%
 lib     lib/runners/processor/hadolint.rb                success           70             11         81      86%
 lib     lib/runners/processor/haml_lint.rb               success          127             18        145      87%
 lib     lib/runners/processor/javasee.rb                 success           49             25         74      66%
 lib     lib/runners/processor/jshint.rb                  success           88              3         91      96%
 lib     lib/runners/processor/ktlint.rb                  success           39             15         54      72%
 lib     lib/runners/processor/languagetool.rb            success          126             20        147      85%
 lib     lib/runners/processor/metrics_codeclone.rb       success           33              2         35      94%
 lib     lib/runners/processor/metrics_complexity.rb      success           39              0         39     100%
 lib     lib/runners/processor/metrics_fileinfo.rb        success          135              0        135     100%
 lib     lib/runners/processor/misspell.rb                success           76              1         78      97%
 lib     lib/runners/processor/phinder.rb                 success           80             36        116      68%
 lib     lib/runners/processor/phpmd.rb                   success          107              1        108      99%
 lib     lib/runners/processor/pmd_cpd.rb                 success          184             22        206      89%
 lib     lib/runners/processor/pmd_java.rb                success          105              5        110      95%
 lib     lib/runners/processor/pylint.rb                  success           64             16         80      80%
 lib     lib/runners/processor/querly.rb                  success           85              6         91      93%
 lib     lib/runners/processor/rails_best_practices.rb    success           98             12        110      89%
 lib     lib/runners/processor/reek.rb                    success           70             12         82      85%
 lib     lib/runners/processor/remark_lint.rb             success           92             26        118      77%
 lib     lib/runners/processor/rubocop.rb                 success          117             31        148      79%
 lib     lib/runners/processor/scss_lint.rb               success           39             10         49      79%
 lib     lib/runners/processor/shellcheck.rb              success          121             18        139      87%
 lib     lib/runners/processor/slim_lint.rb               success          104              3        107      97%
 lib     lib/runners/processor/stylelint.rb               success          137             20        157      87%
 lib     lib/runners/processor/swiftlint.rb               success           69             11         80      86%
 lib     lib/runners/processor/tslint.rb                  success           68             12         80      85%
 lib     lib/runners/processor/tyscan.rb                  success           85             26        111      76%
 lib     lib/runners/python.rb                            success            8              0          8     100%
 lib     lib/runners/recommended_config.rb                success           17              1         18      94%
 lib     lib/runners/results.rb                           success           89              1         90      98%
 lib     lib/runners/rubocop_utils.rb                     success           40              1         41      97%
 lib     lib/runners/ruby.rb                              success           94              5         99      94%
 lib     lib/runners/ruby/gem_installer.rb                success           87              0         87     100%
 lib     lib/runners/ruby/gem_installer/source.rb         success           40              6         46      86%
 lib     lib/runners/ruby/gem_installer/spec.rb           success           24              4         28      85%
 lib     lib/runners/ruby/lockfile_loader.rb              success           44              0         44     100%
 lib     lib/runners/ruby/lockfile_loader/lockfile.rb     success           31              0         31     100%
 lib     lib/runners/ruby/lockfile_parser.rb              success            2              5          7      28%
 lib     lib/runners/schema/config.rb                     success           74              3         77      96%
 lib     lib/runners/schema/options.rb                    success           19              0         19     100%
 lib     lib/runners/schema/result.rb                     success           79              0         79     100%
 lib     lib/runners/schema/trace.rb                      success           80              0         80     100%
 lib     lib/runners/sensitive_filter.rb                  success            9              0          9     100%
 lib     lib/runners/shell.rb                             success           84              7         91      92%
 lib     lib/runners/swift.rb                             success            1              0          1     100%
 lib     lib/runners/tmpdir.rb                            success            6              0          6     100%
 lib     lib/runners/trace_writer.rb                      success           96              2         98      97%
 lib     lib/runners/version.rb                           success            1              0          1     100%
 lib     lib/runners/warnings.rb                          success           18              6         24      75%
 lib     lib/runners/workspace.rb                         success           37              0         37     100%
 lib     lib/runners/workspace/git.rb                     success           61              2         63      96%

@palkan
Copy link
Sponsor

palkan commented Mar 30, 2021

Thanks @soutaro!

Updated the post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants