Skip to content

Support Ruby 3.2.0 #12

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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
19 changes: 8 additions & 11 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Defaults can be found here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml

AllCops:
TargetRubyVersion: 2.1
TargetRubyVersion: 3
NewCops: enable

Style/StringLiterals:
EnforcedStyle: double_quotes
Expand All @@ -11,20 +12,16 @@ Style/StringLiterals:
Style/ClassCheck:
EnforcedStyle: kind_of?

# It's better to be more explicit about the type
Style/BracesAroundHashParameters:
Enabled: false

# specs sometimes have useless assignments, which is fine
Lint/UselessAssignment:
Exclude:
- '**/spec/**/*'

# We could potentially enable the 2 below:
Layout/IndentHash:
Layout/FirstHashElementIndentation:
Enabled: false

Layout/AlignHash:
Layout/HashAlignment:
Enabled: false

# HoundCI doesn't like this rule
Expand Down Expand Up @@ -74,7 +71,7 @@ Metrics/CyclomaticComplexity:
Max: 17

# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
Layout/LineLength:
Max: 370

# Configuration parameters: CountKeywordArgs.
Expand Down Expand Up @@ -125,16 +122,16 @@ Metrics/BlockLength:
Style/MixinGrouping:
Enabled: false

Style/FileName:
Naming/FileName:
Enabled: false

Layout/IndentHeredoc:
Layout/HeredocIndentation:
Enabled: false

Style/SpecialGlobalVars:
Enabled: false

PercentLiteralDelimiters:
Style/PercentLiteralDelimiters:
PreferredDelimiters:
"%": ()
"%i": ()
Expand Down
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.0
181 changes: 101 additions & 80 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,134 +3,155 @@ PATH
specs:
danger-checkstyle_format (0.1.1)
danger-plugin-api (~> 1.0)
ox (~> 2.0)
ox (~> 2.14)

GEM
remote: https://rubygems.org/
specs:
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
ast (2.3.0)
claide (1.0.2)
addressable (2.8.4)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
claide (1.1.0)
claide-plugins (0.9.2)
cork
nap
open4 (~> 1.3)
coderay (1.1.2)
coderay (1.1.3)
colored2 (3.1.2)
cork (0.3.0)
colored2 (~> 3.1)
danger (5.5.5)
danger (9.3.1)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored2 (~> 3.1)
cork (~> 0.1)
faraday (~> 0.9)
faraday-http-cache (~> 1.0)
git (~> 1)
kramdown (~> 1.5)
faraday (>= 0.9.0, < 3.0)
faraday-http-cache (~> 2.0)
git (~> 1.13)
kramdown (~> 2.3)
kramdown-parser-gfm (~> 1.0)
no_proxy_fix
octokit (~> 4.7)
terminal-table (~> 1)
octokit (~> 6.0)
terminal-table (>= 1, < 4)
danger-plugin-api (1.0.0)
danger (> 2.0)
diff-lcs (1.3)
faraday (0.13.1)
multipart-post (>= 1.2, < 3)
faraday-http-cache (1.3.1)
faraday (~> 0.8)
ffi (1.9.18)
formatador (0.2.5)
git (1.3.0)
guard (2.14.1)
diff-lcs (1.5.0)
faraday (2.7.10)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-http-cache (2.5.0)
faraday (>= 0.8)
faraday-net_http (3.0.2)
ffi (1.15.5)
formatador (1.1.0)
git (1.18.0)
addressable (~> 2.8)
rchardet (~> 1.8)
guard (2.18.0)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (~> 1.0)
lumberjack (>= 1.0.12, < 2.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
pry (>= 0.13.0)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
guard-rspec (4.7.3)
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
kramdown (1.16.2)
listen (3.0.7)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9.7)
lumberjack (1.0.12)
method_source (0.9.0)
multipart-post (2.0.0)
json (2.6.3)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
language_server-protocol (3.17.0.3)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
lumberjack (1.2.9)
method_source (1.0.0)
nap (1.1.0)
nenv (0.3.0)
no_proxy_fix (0.1.2)
notiffany (0.1.1)
notiffany (0.1.3)
nenv (~> 0.1)
shellany (~> 0.0)
octokit (4.8.0)
sawyer (~> 0.8.0, >= 0.5.3)
octokit (6.1.1)
faraday (>= 1, < 3)
sawyer (~> 0.9)
open4 (1.3.4)
ox (2.8.2)
parallel (1.12.1)
parser (2.4.0.2)
ast (~> 2.3)
powerpack (0.1.1)
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (3.0.1)
rainbow (3.0.0)
rake (10.5.0)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rspec (3.7.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-core (3.7.0)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
ox (2.14.17)
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1)
racc
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.0.3)
racc (1.7.1)
rainbow (3.1.1)
rake (13.0.6)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rchardet (1.8.0)
regexp_parser (2.8.1)
rexml (3.2.5)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-mocks (3.7.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.6)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.0)
rubocop (0.52.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
rubocop (1.54.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 2.4.0.2, < 3.0)
powerpack (~> 0.1)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.9.0)
sawyer (0.8.1)
addressable (>= 2.3.5, < 2.6)
faraday (~> 0.8, < 1.0)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
shellany (0.0.1)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thor (0.20.0)
unicode-display_width (1.3.0)
yard (0.9.12)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
thor (1.2.2)
unicode-display_width (2.4.2)
yard (0.9.34)

PLATFORMS
ruby

DEPENDENCIES
bundler (~> 1.3)
bundler (~> 2.4)
danger-checkstyle_format!
guard (~> 2.14)
guard (~> 2.18)
guard-rspec (~> 4.7)
listen (= 3.0.7)
listen (= 3.8)
pry
rake (~> 10.0)
rspec (~> 3.4)
rubocop (~> 0.52)
yard (~> 0.9.11)
rake (~> 13.0)
rspec (~> 3.12)
rubocop (~> 1.54)
yard (~> 0.9)

BUNDLED WITH
1.16.1
2.4.17
16 changes: 8 additions & 8 deletions danger-checkstyle_format.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']

spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
spec.add_runtime_dependency 'ox', '~> 2.0'
spec.add_runtime_dependency 'ox', '~> 2.14'

# General ruby development
spec.add_development_dependency 'bundler', '~> 1.3'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'bundler', '~> 2.4'
spec.add_development_dependency 'rake', '~> 13.0'

# Testing support
spec.add_development_dependency 'rspec', '~> 3.4'
spec.add_development_dependency 'rspec', '~> 3.12'

# Linting code and docs
spec.add_development_dependency "rubocop", "~> 0.52"
spec.add_development_dependency "yard", "~> 0.9.11"
spec.add_development_dependency "rubocop", "~> 1.54"
spec.add_development_dependency "yard", "~> 0.9"

# Makes testing easy via `bundle exec guard`
spec.add_development_dependency 'guard', '~> 2.14'
spec.add_development_dependency 'guard', '~> 2.18'
spec.add_development_dependency 'guard-rspec', '~> 4.7'

# If you want to work on older builds of ruby
spec.add_development_dependency 'listen', '3.0.7'
spec.add_development_dependency 'listen', '3.8'

# This gives you the chance to run a REPL inside your tests
# via:
Expand Down
4 changes: 3 additions & 1 deletion lib/checkstyle_format/checkstyle_error.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# frozen_string_literal: true

CheckstyleError = Struct.new(:file_name, :line, :column, :severity, :message, :source) do
def self.generate(node, parent_node, base_path)
CheckstyleError.new(
parent_node[:name].sub(/^#{base_path}/, ""),
node[:line].to_i,
node[:column].nil? ? nil : node[:column].to_i,
node[:column]&.to_i,
node[:severity],
node[:message],
node[:source]
Expand Down
4 changes: 3 additions & 1 deletion lib/checkstyle_format/gem_version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module CheckstyleFormat
VERSION = "0.1.1".freeze
VERSION = "0.1.1"
end
12 changes: 7 additions & 5 deletions lib/checkstyle_format/plugin.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative "checkstyle_error"

module Danger
Expand Down Expand Up @@ -25,9 +27,10 @@ class DangerCheckstyleFormat < Plugin
# Report checkstyle warnings
#
# @return [void]
def report(file, inline_mode = true)
def report(file, inline_mode: true)
raise "Please specify file name." if file.empty?
raise "No checkstyle file was found at #{file}" unless File.exist? file

errors = parse(File.read(file))

send_comment(errors, inline_mode)
Expand All @@ -36,8 +39,9 @@ def report(file, inline_mode = true)
# Report checkstyle warnings by XML text
#
# @return [void]
def report_by_text(text, inline_mode = true)
def report_by_text(text, inline_mode: true)
raise "Please specify xml text." if text.empty?

errors = parse(text)

send_comment(errors, inline_mode)
Expand All @@ -54,13 +58,11 @@ def parse(text)
end
base_path_suffix = @base_path.end_with?("/") ? "" : "/"
base_path = @base_path + base_path_suffix
elements = present_elements.flat_map do |parent|
present_elements.flat_map do |parent|
parent.nodes.map do |child|
CheckstyleError.generate(child, parent, base_path)
end
end

elements
end

def send_comment(errors, inline_mode)
Expand Down
Loading