Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2025-10-17 22:53:06 UTC using RuboCop version 1.81.1.
# on 2025-11-14 17:50:37 UTC using RuboCop version 1.81.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -24,21 +24,21 @@ Lint/MissingSuper:
- 'lib/skunk/cli/application.rb'
- 'lib/skunk/generators/html/overview.rb'

# Offense count: 4
# Offense count: 5
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 24

# Offense count: 14
# Offense count: 13
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 208

# Offense count: 5
# Offense count: 7
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 18
Max: 20

# Offense count: 1
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
Expand Down Expand Up @@ -66,10 +66,3 @@ Style/FrozenStringLiteralComment:
Exclude:
- '**/*.arb'
- 'bin/console'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
# URISchemes: http, https
Layout/LineLength:
Max: 124
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## main [(unreleased)](https://github.com/fastruby/skunk/compare/v0.5.4...HEAD)

* BUGFIX: Pin path_expander < 2.0 for Ruby 2.7 compatibility
* [FEATURE: Add `--formats` CLI flag to select report formats (json, html, console)](https://github.com/fastruby/skunk/pull/130)
* [REFACTOR: Move Console Report](https://github.com/fastruby/skunk/pull/128)
* [BUGFIX: Set the right content type in the share HTTP request](https://github.com/fastruby/skunk/pull/129)
* [REFACTOR: Centralize Skunk analysis into RubyCritic module](https://github.com/fastruby/skunk/pull/127)
Expand Down
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,33 @@ This should give you an idea if you're moving in the direction of maintaining th

### Setting Output Formats

Skunk provides a simple configuration class to control output formats programmatically. You can use `Skunk::Config` to set which formats should be generated when running Skunk.
Skunk supports multiple output formats and you can select them via CLI or programmatically.

**Supported formats:**
- `:json` - JSON report (default)
- `:json` - JSON report
- `:html` - HTML report with visual charts and tables
- `:console` - Console output (default)

#### CLI flag

You can choose one or more formats from the command line:

```
skunk --formats=json
skunk --f json,html
skunk --formats console,json
```

If omitted, Skunk defaults to `console`.

#### Programmatic configuration

You can also configure formats in code using `Skunk::Config`:

```ruby
require 'skunk/config'

# Set multiple formats
# Set multiple formats (equivalent to `--formats=json,html`)
Skunk::Config.formats = [:json, :html]

# Add a format to the existing list
Expand All @@ -177,7 +194,7 @@ Skunk::Config.add_format(:html)
Skunk::Config.remove_format(:json)

# Check supported formats
Skunk::Config.supported_formats # => [:json, :html]
Skunk::Config.supported_formats # => [:json, :html, :console]
Skunk::Config.supported_format?(:json) # => true

# Reset to defaults
Expand Down
1 change: 1 addition & 0 deletions lib/skunk/cli/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def initialize(argv)
def execute
warn_coverage_info unless File.exist?(COVERAGE_FILE)

Skunk::Config.reset
Copy link
Member Author

@JuanVqz JuanVqz Feb 5, 2026

Choose a reason for hiding this comment

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

https://gist.github.com/etagwerker/9ac9d8e20b5f5a4789b5fe263946c211
1 or 2 out of 10 test executions will fail with something like that.

Fix for ^

Resetting the format key to console fixed it.

# :reek:NilCheck
@parsed_options = @options.parse.to_h
command = Skunk::CommandFactory.create(@parsed_options)
Expand Down
58 changes: 41 additions & 17 deletions lib/skunk/cli/options/argv.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require "rubycritic/cli/options/argv"
require "skunk/config"

module Skunk
module Cli
Expand All @@ -15,29 +16,52 @@ class Argv < RubyCritic::Cli::Options::Argv
def parse
parser.new do |opts|
opts.banner = "Usage: skunk [options] [paths]\n"
add_branch_option(opts)
add_output_option(opts)
add_formats_option(opts)
add_tail_options(opts)
end.parse!(@argv)
end

def to_h
super.merge(output_filename: output_filename)
end

opts.on("-b", "--branch BRANCH", "Set branch to compare") do |branch|
self.base_branch = String(branch)
set_current_branch
self.mode = :compare_branches
end
private

opts.on("-o", "--out FILE", "Output report to file") do |filename|
self.output_filename = filename
end
def add_branch_option(opts)
opts.on("-b", "--branch BRANCH", "Set branch to compare") do |branch|
self.base_branch = String(branch)
set_current_branch
self.mode = :compare_branches
end
end

opts.on_tail("-v", "--version", "Show gem's version") do
self.mode = :version
end
def add_output_option(opts)
opts.on("-o", "--out FILE", "Output report to file") do |filename|
self.output_filename = filename
end
end

opts.on_tail("-h", "--help", "Show this message") do
self.mode = :help
end
end.parse!(@argv)
def add_formats_option(opts)
opts.on(
"-f",
"--formats json,html,console",
Array,
"Output formats: json,html,console (default: console)"
) do |list|
Skunk::Config.formats = Array(list).map(&:to_sym)
end
end

def to_h
super.merge(output_filename: output_filename)
def add_tail_options(opts)
opts.on_tail("-v", "--version", "Show gem's version") do
self.mode = :version
end

opts.on_tail("-h", "--help", "Show this message") do
self.mode = :help
end
end
end
end
Expand Down
1 change: 1 addition & 0 deletions skunk.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency "path_expander", "< 2.0"
Copy link
Member Author

@JuanVqz JuanVqz Feb 5, 2026

Choose a reason for hiding this comment

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

Unfortunately now I'm getting non-deterministic failures from the test suite, and it seems to be related to these changes.

Fix for ^

path_expander is a transitive dependency of flay, which is used by rubycritic, which Skunk depends on. So even though you don’t require it directly, it ends up in your bundle via rubycritic -> flay -> path_expander, and this is because rubycritic now only supports Ruby 3+

spec.add_dependency "rubycritic", ">= 4.5.2", "< 5.0"
spec.add_dependency "terminal-table", "~> 3.0"

Expand Down
24 changes: 24 additions & 0 deletions test/lib/skunk/cli/options/argv_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,28 @@
end
end
end

describe "#formats" do
after do
Skunk::Config.reset
end

context "passing --formats option" do
let(:argv) { ["--formats=json,html"] }

it "applies formats to Skunk::Config" do
parser = Skunk::Cli::Options::Argv.new(argv)
parser.parse
_(Skunk::Config.formats).must_equal %i[json html]
end
end

context "not passing --formats option" do
it "defaults to console format" do
parser = Skunk::Cli::Options::Argv.new([])
parser.parse
_(Skunk::Config.formats).must_equal [:console]
end
end
end
end
1 change: 1 addition & 0 deletions test/lib/skunk/commands/help_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Usage: skunk [options] [paths]
-b, --branch BRANCH Set branch to compare
-o, --out FILE Output report to file
-f, --formats json,html,console Output formats: json,html,console (default: console)
-v, --version Show gem's version
-h, --help Show this message
HELP
Expand Down