diff --git a/.rubocop.yml b/.rubocop.yml index 762eebb..640440a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,5 @@ +inherit_from: .rubocop_todo.yml + AllCops: TargetRubyVersion: 3.0 diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..df9425d --- /dev/null +++ b/.rubocop_todo.yml @@ -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' diff --git a/lib/poepod/cli.rb b/lib/poepod/cli.rb index 0c3e2cc..11203f2 100644 --- a/lib/poepod/cli.rb +++ b/lib/poepod/cli.rb @@ -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 @@ -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) diff --git a/lib/poepod/processor.rb b/lib/poepod/processor.rb index 5245ae3..4d8810b 100644 --- a/lib/poepod/processor.rb +++ b/lib/poepod/processor.rb @@ -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( @@ -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) @@ -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" @@ -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}"