Skip to content

[#30] Explicitly set format as text for Bundler::Stats::CLI on ConsoleFormatter.#43

Open
ruyrocha wants to merge 3 commits intofastruby:mainfrom
ruyrocha:hotfix/console-formatter
Open

[#30] Explicitly set format as text for Bundler::Stats::CLI on ConsoleFormatter.#43
ruyrocha wants to merge 3 commits intofastruby:mainfrom
ruyrocha:hotfix/console-formatter

Conversation

@ruyrocha
Copy link
Copy Markdown

Closes #30

  • Add an entry to CHANGELOG.md that links to this PR under the "main (unreleased)" heading.

Description:

Bundler::Stats::CLI was failing to display console output, and now it's fixed by setting the format as text.

I will abide by the code of conduct.

@ruyrocha ruyrocha force-pushed the hotfix/console-formatter branch from edcf9e4 to ae05704 Compare June 14, 2025 15:35
@ruyrocha
Copy link
Copy Markdown
Author

main branch

 ~/G/rails_stats (main)> bundle exec rake stats\[points,stdout\]

Directory: /home/ruy/GitHub/rails_stats/points

Could not find command "stats[points,stdout]".
 ~/G/rails_stats (main) [1]>

this branch

 ~/G/rails_stats (hotfix/console-formatter)> bundle exec rake stats\[points,stdout\]

Directory: /home/ruy/GitHub/rails_stats/points

The dependency `bundler` wasn't found. It may not be present in your Gemfile.lock. This often happens when a dependency isn't installed on your platform.
The dependency `bundler` wasn't found. It may not be present in your Gemfile.lock. This often happens when a dependency isn't installed on your platform.
+-----------------------|------------|----------------+
|                  Name | Total Deps | 1st Level Deps |
+-----------------------|------------|----------------+
|     simplecov-console | 8          | 3              |
|               codecov | 4          | 1              |
|           rails_stats | 4          | 2              |
|             simplecov | 3          | 3              |
|       minitest-around | 1          | 1              |
|               bundler | 0          | 0              |
|                byebug | 0          | 0              |
|              minitest | 0          | 0              |
| minitest-spec-context | 0          | 0              |
+-----------------------|------------|----------------+

      Declared Gems   9
         Total Gems   18
  Unpinned Versions   6
        Github Refs   0

+----------------------+---------+---------+---------+---------+---------+-----+-------+
| Name                 | Files   | Lines   |     LOC | Classes | Methods | M/C | LOC/M |
+----------------------+---------+---------+---------+---------+---------+-----+-------+
| Channels             |       2 |       8 |       8 |       2 |       0 |   0 |     0 |
| Configuration        |      21 |     431 |     160 |       1 |       0 |   0 |     0 |
| Controller Tests     |       5 |     856 |     684 |       0 |       0 |   0 |     0 |
| Controllers          |      15 |     591 |     502 |      15 |      69 |   4 |     5 |
| Feature Tests        |      10 |    1392 |    1063 |       0 |       1 |   0 |  1061 |
| Helper Tests         |       1 |      10 |       9 |       0 |       0 |   0 |     0 |
| Helpers              |       6 |     126 |     103 |       0 |      17 |   0 |     4 |
| Javascripts          |       8 |     294 |     225 |       0 |      18 |   0 |    10 |
| Jobs                 |       1 |       2 |       2 |       1 |       0 |   0 |     0 |
| Madmins              |       5 |     124 |      54 |       5 |       4 |   0 |    11 |
| Mailers              |       1 |       4 |       4 |       1 |       0 |   0 |     0 |
| Model Tests          |       6 |     362 |     294 |       0 |       1 |   0 |   292 |
| Models               |       8 |     245 |     188 |       8 |      30 |   3 |     4 |
| Policies             |       6 |      84 |      65 |       7 |      14 |   2 |     2 |
| Policy Tests         |       1 |      37 |      29 |       0 |       0 |   0 |     0 |
| Spec Support         |      10 |     343 |     180 |       0 |       6 |   0 |    28 |
+----------------------+---------+---------+---------+---------+---------+-----+-------+
| Code                 |      73 |    1909 |    1311 |      40 |     152 |   3 |     6 |
| Tests                |      33 |    3000 |    2259 |       0 |       8 |   0 |   280 |
| Total                |     106 |    4909 |    3570 |      40 |     160 |   4 |    20 |
+----------------------+---------+---------+---------+---------+---------+-----+-------+
  Code LOC: 1311     Test LOC: 2259     Code to Test Ratio: 1:1.7  Files: 106

  Polymorphic models count: 0 polymorphic associations
  Schema Stats: 6 `create_table` calls in schema.rb
 ~/G/rails_stats (hotfix/console-formatter)>

Copy link
Copy Markdown
Member

@JuanVqz JuanVqz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ruyrocha sorry for the delay; this change looks right to me. could you please update your PR to let the tests run on it, and if all is green, we can merge.

Extra points: (Optional)
It would be great if you could add tests for the fix.

Ping me when done. thanks!

class ConsoleFormatter < StatsFormatter
def to_s
Bundler::Stats::CLI.start
Bundler::Stats::CLI.start(['--format', 'text'])
Copy link
Copy Markdown
Member

@JuanVqz JuanVqz Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested the command; although it works, please consider being more explicit by including the stats subcommand.

Thor may be defaulting to stats but this makes the intent clearer and less reliant on Thor's default behavior.

Suggested change
Bundler::Stats::CLI.start(['--format', 'text'])
Bundler::Stats::CLI.start(['stats', '--format', 'text'])

Without stats

➜ Bundler::Stats::CLI.start(['--format', 'text'])"
The dependency `bundler` wasn't found. It may not be present in your Gemfile.lock. This often happens when a dependency isn't installed on your platform.
The dependency `bundler` wasn't found. It may not be present in your Gemfile.lock. This often happens when a dependency isn't installed on your platform.
+-----------------------|------------|----------------+
|                  Name | Total Deps | 1st Level Deps |
+-----------------------|------------|----------------+
|     simplecov-console | 8          | 3              |
|               codecov | 4          | 1              |
|           rails_stats | 4          | 2              |
|             simplecov | 3          | 3              |
|       minitest-around | 1          | 1              |
|               bundler | 0          | 0              |
|                byebug | 0          | 0              |
|              minitest | 0          | 0              |
| minitest-spec-context | 0          | 0              |
+-----------------------|------------|----------------+

      Declared Gems   9
         Total Gems   18
  Unpinned Versions   6
        Github Refs   0

With stats

➜ Bundler::Stats::CLI.start(['stats', '--format', 'text'])"
The dependency `bundler` wasn't found. It may not be present in your Gemfile.lock. This often happens when a dependency isn't installed on your platform.
The dependency `bundler` wasn't found. It may not be present in your Gemfile.lock. This often happens when a dependency isn't installed on your platform.
+-----------------------|------------|----------------+
|                  Name | Total Deps | 1st Level Deps |
+-----------------------|------------|----------------+
|     simplecov-console | 8          | 3              |
|               codecov | 4          | 1              |
|           rails_stats | 4          | 2              |
|             simplecov | 3          | 3              |
|       minitest-around | 1          | 1              |
|               bundler | 0          | 0              |
|                byebug | 0          | 0              |
|              minitest | 0          | 0              |
| minitest-spec-context | 0          | 0              |
+-----------------------|------------|----------------+

      Declared Gems   9
         Total Gems   18
  Unpinned Versions   6
        Github Refs   0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ruyrocha Do you think committing this is a good addition?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ruyrocha Do you think committing this is a good addition?

I'll revisit this (plus tests) later today; I didn't double-check but I have the sense stats is already being chained.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ruyrocha, would appreciate that; feel free to ping me when you are done. 👍

@JuanVqz JuanVqz mentioned this pull request Mar 31, 2026
1 task
@sentry
Copy link
Copy Markdown

sentry bot commented Apr 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.20%. Comparing base (3a87be4) to head (b89ee49).
⚠️ Report is 17 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #43   +/-   ##
=======================================
  Coverage   83.20%   83.20%           
=======================================
  Files          19       19           
  Lines         750      750           
=======================================
  Hits          624      624           
  Misses        126      126           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Co-authored-by: Juan Vásquez <javasgon@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running rake task from outside of the Rails app directory is not working as expected

2 participants