Skip to content

Commit

Permalink
chore: rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldtse committed Oct 28, 2024
1 parent d62dd0e commit d537b15
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 3.0

Expand Down
122 changes: 122 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-10-28 08:08:05 UTC using RuboCop version 1.67.0.
# 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
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Layout/ElseAlignment:
Exclude:
- 'lib/poepod/processor.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Layout/EmptyLineAfterMagicComment:
Exclude:
- 'lib/poepod/file_processor.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleAlignWith, Severity.
# SupportedStylesAlignWith: keyword, variable, start_of_line
Layout/EndAlignment:
Exclude:
- 'lib/poepod/processor.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Width, AllowedPatterns.
Layout/IndentationWidth:
Exclude:
- 'lib/poepod/processor.rb'

# Offense count: 5
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AutoCorrect.
Lint/UselessAssignment:
Exclude:
- 'lib/poepod/gem_processor.rb'
- 'spec/poepod/gem_processor_spec.rb'

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

# Offense count: 12
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 158

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 105

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

# Offense count: 2
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
Metrics/ParameterLists:
Max: 7

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Exclude:
- 'lib/poepod/file_processor.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/IfUnlessModifier:
Exclude:
- 'lib/poepod/processor.rb'

# Offense count: 1
Style/OptionalArguments:
Exclude:
- 'lib/poepod/processor.rb'

# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInArguments:
Exclude:
- 'lib/poepod/cli.rb'
- 'lib/poepod/processor.rb'
- 'spec/poepod/file_processor_spec.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInArrayLiteral:
Exclude:
- 'lib/poepod/processor.rb'
- 'spec/poepod/gem_processor_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInHashLiteral:
Exclude:
- 'spec/poepod/gem_processor_spec.rb'

# Offense count: 6
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowNamedUnderscoreVariables.
Style/TrailingUnderscoreVariable:
Exclude:
- 'lib/poepod/gem_processor.rb'
- 'spec/poepod/gem_processor_spec.rb'
4 changes: 2 additions & 2 deletions lib/poepod/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def wrap(gemspec_path)
include_binary: options[:include_binary],
include_dot_files: options[:include_dot_files],
base_dir: base_dir,
config_file: options[:config],
config_file: options[:config]
)
success, result, unstaged_files = processor.process(output_file)
if success
Expand Down Expand Up @@ -81,7 +81,7 @@ def process_files(files, output_file, base_dir)
include_binary: options[:include_binary],
include_dot_files: options[:include_dot_files],
exclude: options[:exclude],
base_dir: base_dir,
base_dir: base_dir
)
total_files, copied_files = processor.process(output_path.to_s)
print_result(total_files, copied_files, output_path)
Expand Down
16 changes: 7 additions & 9 deletions lib/poepod/processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Poepod
# Base processor class
class Processor
EXCLUDE_DEFAULT = [
%r{node_modules/}, %r{.git/}, /.gitignore$/, /.DS_Store$/,
%r{node_modules/}, %r{.git/}, /.gitignore$/, /.DS_Store$/
].freeze

def initialize(
Expand Down Expand Up @@ -56,9 +56,7 @@ def collect_files_to_process

def collect_files_from_pattern(pattern)
expanded_pattern = File.expand_path(pattern)
if File.directory?(expanded_pattern)
expanded_pattern = File.join(expanded_pattern, "**", "*")
end
expanded_pattern = File.join(expanded_pattern, "**", "*") if File.directory?(expanded_pattern)

Dir.glob(expanded_pattern, File::FNM_DOTMATCH).each_with_object([]) do |file_path, acc|
next unless File.file?(file_path)
Expand All @@ -82,7 +80,7 @@ def binary_file?(file_path)
mime_type = Marcel::MimeType.for(
content,
name: File.basename(file_path),
declared_type: "text/plain",
declared_type: "text/plain"
)

!mime_type.start_with?("text/") && mime_type != "application/json"
Expand All @@ -93,10 +91,10 @@ def process_file(output = nil, file_path)
output ||= StringIO.new

relative_path = if @base_dir
Pathname.new(file_path).relative_path_from(@base_dir).to_s
else
file_path
end
Pathname.new(file_path).relative_path_from(@base_dir).to_s
else
file_path
end

puts "Adding to bundle: #{relative_path}"

Expand Down

0 comments on commit d537b15

Please sign in to comment.