From d4bce13269031decde4e752cf8b894a441e3cdac Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Mon, 30 Jun 2025 11:14:46 -0400 Subject: [PATCH 1/8] Update ci.yml Co-authored-by: Pieter Oliver <68863060+pieterocp@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df04c74..0c5fe4c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,5 +32,5 @@ jobs: bundler-cache: true - name: Install dependencies run: bundle install - - name: Run tests + - name: Run RuboCop run: bundle exec rake rubocop From df63cfe0ce34295af2f07e1c53af50b44e6aa6c5 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Mon, 30 Jun 2025 09:33:48 -0700 Subject: [PATCH 2/8] WIP: Remove claude-scratchpad cruft from rubocop todo --- .rubocop_todo.yml | 218 ++++++++++++++++++---------------------------- 1 file changed, 86 insertions(+), 132 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8aa26da..4f886bc 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -12,7 +12,7 @@ # Include: **/*.gemspec, **/Gemfile, **/gems.rb Gemspec/DevelopmentDependencies: Exclude: - - 'grape_logging.gemspec' + - "grape_logging.gemspec" # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). @@ -20,36 +20,27 @@ Gemspec/DevelopmentDependencies: # Include: **/*.gemspec Gemspec/RequireMFA: Exclude: - - 'grape_logging.gemspec' + - "grape_logging.gemspec" # Offense count: 1 # Configuration parameters: Severity, Include. # Include: **/*.gemspec Gemspec/RequiredRubyVersion: Exclude: - - 'grape_logging.gemspec' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth. -# SupportedStyles: case, end -Layout/CaseIndentation: - Exclude: - - 'claude-scratchpad/cleaner_parameter_filter.rb' + - "grape_logging.gemspec" # Offense count: 4 # This cop supports safe autocorrection (--autocorrect). Layout/ElseAlignment: Exclude: - - 'claude-scratchpad/cleaner_parameter_filter.rb' - - 'lib/grape_logging/middleware/request_logger.rb' - - 'spec/lib/grape_logging/formatters/rails_spec.rb' + - "lib/grape_logging/middleware/request_logger.rb" + - "spec/lib/grape_logging/formatters/rails_spec.rb" # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Layout/EmptyLines: Exclude: - - 'spec/lib/grape_logging/loggers/filter_parameters_spec.rb' + - "spec/lib/grape_logging/loggers/filter_parameters_spec.rb" # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). @@ -57,7 +48,7 @@ Layout/EmptyLines: # SupportedStyles: around, only_before Layout/EmptyLinesAroundAccessModifier: Exclude: - - 'lib/grape_logging/formatters/default.rb' + - "lib/grape_logging/formatters/default.rb" # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). @@ -65,7 +56,7 @@ Layout/EmptyLinesAroundAccessModifier: # SupportedStyles: empty_lines, no_empty_lines Layout/EmptyLinesAroundBlockBody: Exclude: - - 'spec/lib/grape_logging/formatters/rails_spec.rb' + - "spec/lib/grape_logging/formatters/rails_spec.rb" # Offense count: 5 # This cop supports safe autocorrection (--autocorrect). @@ -73,15 +64,15 @@ Layout/EmptyLinesAroundBlockBody: # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only Layout/EmptyLinesAroundClassBody: Exclude: - - 'lib/grape_logging/formatters/rails.rb' - - 'lib/grape_logging/loggers/request_headers.rb' - - 'lib/grape_logging/middleware/request_logger.rb' + - "lib/grape_logging/formatters/rails.rb" + - "lib/grape_logging/loggers/request_headers.rb" + - "lib/grape_logging/middleware/request_logger.rb" # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Layout/EmptyLinesAroundMethodBody: Exclude: - - 'lib/grape_logging/loggers/response.rb' + - "lib/grape_logging/loggers/response.rb" # Offense count: 7 # This cop supports safe autocorrection (--autocorrect). @@ -89,16 +80,15 @@ Layout/EmptyLinesAroundMethodBody: # SupportedStylesAlignWith: keyword, variable, start_of_line Layout/EndAlignment: Exclude: - - 'claude-scratchpad/cleaner_parameter_filter.rb' - - 'lib/grape_logging/middleware/request_logger.rb' - - 'spec/lib/grape_logging/formatters/rails_spec.rb' + - "lib/grape_logging/middleware/request_logger.rb" + - "spec/lib/grape_logging/formatters/rails_spec.rb" # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. Layout/ExtraSpacing: Exclude: - - 'lib/grape_logging/util/parameter_filter.rb' + - "lib/grape_logging/util/parameter_filter.rb" # Offense count: 26 # This cop supports safe autocorrection (--autocorrect). @@ -115,16 +105,15 @@ Layout/FirstHashElementIndentation: # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit Layout/HashAlignment: Exclude: - - 'spec/lib/grape_logging/loggers/request_headers_spec.rb' + - "spec/lib/grape_logging/loggers/request_headers_spec.rb" # Offense count: 5 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Width, AllowedPatterns. Layout/IndentationWidth: Exclude: - - 'claude-scratchpad/cleaner_parameter_filter.rb' - - 'lib/grape_logging/middleware/request_logger.rb' - - 'spec/lib/grape_logging/formatters/rails_spec.rb' + - "lib/grape_logging/middleware/request_logger.rb" + - "spec/lib/grape_logging/formatters/rails_spec.rb" # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). @@ -133,7 +122,7 @@ Layout/IndentationWidth: # SupportedStylesForRationalLiterals: space, no_space Layout/SpaceAroundOperators: Exclude: - - 'spec/lib/grape_logging/loggers/request_headers_spec.rb' + - "spec/lib/grape_logging/loggers/request_headers_spec.rb" # Offense count: 6 # This cop supports safe autocorrection (--autocorrect). @@ -142,16 +131,16 @@ Layout/SpaceAroundOperators: # SupportedStylesForEmptyBraces: space, no_space Layout/SpaceBeforeBlockBraces: Exclude: - - 'lib/grape_logging/formatters/rails.rb' - - 'lib/grape_logging/loggers/filter_parameters.rb' - - 'lib/grape_logging/loggers/response.rb' - - 'spec/lib/grape_logging/middleware/request_logger_spec.rb' + - "lib/grape_logging/formatters/rails.rb" + - "lib/grape_logging/loggers/filter_parameters.rb" + - "lib/grape_logging/loggers/response.rb" + - "spec/lib/grape_logging/middleware/request_logger_spec.rb" # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). Layout/SpaceBeforeComma: Exclude: - - 'spec/lib/grape_logging/middleware/request_logger_spec.rb' + - "spec/lib/grape_logging/middleware/request_logger_spec.rb" # Offense count: 4 # This cop supports safe autocorrection (--autocorrect). @@ -160,8 +149,8 @@ Layout/SpaceBeforeComma: # SupportedStylesForEmptyBraces: space, no_space Layout/SpaceInsideBlockBraces: Exclude: - - 'lib/grape_logging/formatters/rails.rb' - - 'lib/grape_logging/multi_io.rb' + - "lib/grape_logging/formatters/rails.rb" + - "lib/grape_logging/multi_io.rb" # Offense count: 16 # This cop supports safe autocorrection (--autocorrect). @@ -170,10 +159,10 @@ Layout/SpaceInsideBlockBraces: # SupportedStylesForEmptyBraces: space, no_space Layout/SpaceInsideHashLiteralBraces: Exclude: - - 'spec/lib/grape_logging/loggers/filter_parameters_spec.rb' - - 'spec/lib/grape_logging/loggers/request_headers_spec.rb' - - 'spec/lib/grape_logging/loggers/response_spec.rb' - - 'spec/lib/grape_logging/middleware/request_logger_spec.rb' + - "spec/lib/grape_logging/loggers/filter_parameters_spec.rb" + - "spec/lib/grape_logging/loggers/request_headers_spec.rb" + - "spec/lib/grape_logging/loggers/response_spec.rb" + - "spec/lib/grape_logging/middleware/request_logger_spec.rb" # Offense count: 4 # This cop supports safe autocorrection (--autocorrect). @@ -181,34 +170,21 @@ Layout/SpaceInsideHashLiteralBraces: # SupportedStyles: final_newline, final_blank_line Layout/TrailingEmptyLines: Exclude: - - 'claude-scratchpad/cleaner_parameter_filter.rb' - - 'lib/grape_logging/multi_io.rb' - - 'lib/grape_logging/reporters/active_support_reporter.rb' - - 'lib/grape_logging/timings.rb' - -# Offense count: 11 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowInHeredoc. -Layout/TrailingWhitespace: - Exclude: - - 'claude-scratchpad/cleaner_parameter_filter.rb' + - "lib/grape_logging/multi_io.rb" + - "lib/grape_logging/reporters/active_support_reporter.rb" + - "lib/grape_logging/timings.rb" # Offense count: 1 # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch. Lint/DuplicateBranch: Exclude: - - 'lib/grape_logging/util/parameter_filter.rb' - -# Offense count: 6 -Lint/HashCompareByIdentity: - Exclude: - - 'claude-scratchpad/cleaner_parameter_filter.rb' + - "lib/grape_logging/util/parameter_filter.rb" # Offense count: 1 # Configuration parameters: AllowedParentClasses. Lint/MissingSuper: Exclude: - - 'lib/grape_logging/loggers/filter_parameters.rb' + - "lib/grape_logging/loggers/filter_parameters.rb" # Offense count: 3 # This cop supports safe autocorrection (--autocorrect). @@ -216,7 +192,7 @@ Lint/MissingSuper: # SupportedStyles: strict, consistent Lint/SymbolConversion: Exclude: - - 'spec/lib/grape_logging/loggers/response_spec.rb' + - "spec/lib/grape_logging/loggers/response_spec.rb" # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). @@ -224,19 +200,7 @@ Lint/SymbolConversion: # NotImplementedExceptions: NotImplementedError Lint/UnusedMethodArgument: Exclude: - - 'lib/grape_logging/loggers/base.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect. -Lint/UselessAssignment: - Exclude: - - 'claude-scratchpad/cleaner_parameter_filter.rb' - -# Offense count: 1 -Lint/UselessConstantScoping: - Exclude: - - 'claude-scratchpad/cleaner_parameter_filter.rb' + - "lib/grape_logging/loggers/base.rb" # Offense count: 4 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. @@ -270,13 +234,13 @@ Metrics/PerceivedComplexity: # AllowedIdentifiers: TLS1_1, TLS1_2, capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64 Naming/VariableNumber: Exclude: - - 'spec/lib/grape_logging/formatters/rails_spec.rb' + - "spec/lib/grape_logging/formatters/rails_spec.rb" # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Style/BlockComments: Exclude: - - 'spec/spec_helper.rb' + - "spec/spec_helper.rb" # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). @@ -287,16 +251,16 @@ Style/BlockComments: # AllowedMethods: lambda, proc, it Style/BlockDelimiters: Exclude: - - 'spec/lib/grape_logging/formatters/rails_spec.rb' + - "spec/lib/grape_logging/formatters/rails_spec.rb" # Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: MinBranchesCount. Style/CaseLikeIf: Exclude: - - 'lib/grape_logging/formatters/default.rb' - - 'lib/grape_logging/formatters/logstash.rb' - - 'lib/grape_logging/formatters/rails.rb' + - "lib/grape_logging/formatters/default.rb" + - "lib/grape_logging/formatters/logstash.rb" + - "lib/grape_logging/formatters/rails.rb" # Offense count: 18 # Configuration parameters: AllowedConstants. @@ -307,7 +271,7 @@ Style/Documentation: # This cop supports safe autocorrection (--autocorrect). Style/ExpandPathArguments: Exclude: - - 'grape_logging.gemspec' + - "grape_logging.gemspec" # Offense count: 30 # This cop supports unsafe autocorrection (--autocorrect-all). @@ -320,14 +284,14 @@ Style/FrozenStringLiteralComment: # This cop supports unsafe autocorrection (--autocorrect-all). Style/GlobalStdStream: Exclude: - - 'lib/grape_logging/reporters/logger_reporter.rb' + - "lib/grape_logging/reporters/logger_reporter.rb" # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. Style/GuardClause: Exclude: - - 'lib/grape_logging/reporters/logger_reporter.rb' + - "lib/grape_logging/reporters/logger_reporter.rb" # Offense count: 3 # This cop supports safe autocorrection (--autocorrect). @@ -336,14 +300,13 @@ Style/GuardClause: # SupportedShorthandSyntax: always, never, either, consistent, either_consistent Style/HashSyntax: Exclude: - - 'lib/grape_logging/formatters/logstash.rb' + - "lib/grape_logging/formatters/logstash.rb" # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). Style/IfUnlessModifier: Exclude: - - 'claude-scratchpad/cleaner_parameter_filter.rb' - - 'lib/grape_logging/reporters/logger_reporter.rb' + - "lib/grape_logging/reporters/logger_reporter.rb" # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). @@ -351,8 +314,8 @@ Style/IfUnlessModifier: # SupportedStyles: line_count_dependent, lambda, literal Style/Lambda: Exclude: - - 'lib/grape_logging/util/parameter_filter.rb' - - 'spec/lib/grape_logging/loggers/filter_parameters_spec.rb' + - "lib/grape_logging/util/parameter_filter.rb" + - "spec/lib/grape_logging/loggers/filter_parameters_spec.rb" # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). @@ -360,13 +323,13 @@ Style/Lambda: # SupportedStyles: module_function, extend_self, forbidden Style/ModuleFunction: Exclude: - - 'lib/grape_logging/timings.rb' + - "lib/grape_logging/timings.rb" # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Style/MultilineIfModifier: Exclude: - - 'lib/grape_logging/middleware/request_logger.rb' + - "lib/grape_logging/middleware/request_logger.rb" # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). @@ -374,15 +337,7 @@ Style/MultilineIfModifier: # SupportedStyles: literals, strict Style/MutableConstant: Exclude: - - 'lib/grape_logging/version.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, MinBodyLength, AllowConsecutiveConditionals. -# SupportedStyles: skip_modifier_ifs, always -Style/Next: - Exclude: - - 'claude-scratchpad/cleaner_parameter_filter.rb' + - "lib/grape_logging/version.rb" # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). @@ -390,30 +345,30 @@ Style/Next: # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: - - 'spec/**/*' - - 'lib/grape_logging/formatters/rails.rb' + - "spec/**/*" + - "lib/grape_logging/formatters/rails.rb" # Offense count: 10 Style/OpenStructUse: Exclude: - - 'spec/lib/grape_logging/loggers/client_env_spec.rb' - - 'spec/lib/grape_logging/loggers/filter_parameters_spec.rb' - - 'spec/lib/grape_logging/loggers/request_headers_spec.rb' - - 'spec/lib/grape_logging/loggers/response_spec.rb' + - "spec/lib/grape_logging/loggers/client_env_spec.rb" + - "spec/lib/grape_logging/loggers/filter_parameters_spec.rb" + - "spec/lib/grape_logging/loggers/request_headers_spec.rb" + - "spec/lib/grape_logging/loggers/response_spec.rb" # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Style/ParallelAssignment: Exclude: - - 'lib/grape_logging/util/parameter_filter.rb' + - "lib/grape_logging/util/parameter_filter.rb" # Offense count: 3 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: PreferredDelimiters. Style/PercentLiteralDelimiters: Exclude: - - 'grape_logging.gemspec' - - 'lib/grape_logging/loggers/filter_parameters.rb' + - "grape_logging.gemspec" + - "lib/grape_logging/loggers/filter_parameters.rb" # Offense count: 3 # This cop supports safe autocorrection (--autocorrect). @@ -421,19 +376,19 @@ Style/PercentLiteralDelimiters: # SupportedStyles: same_as_string_literals, single_quotes, double_quotes Style/QuotedSymbols: Exclude: - - 'spec/lib/grape_logging/loggers/response_spec.rb' + - "spec/lib/grape_logging/loggers/response_spec.rb" # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Style/RedundantConstantBase: Exclude: - - 'lib/grape_logging/util/parameter_filter.rb' + - "lib/grape_logging/util/parameter_filter.rb" # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). Style/RedundantPercentQ: Exclude: - - 'grape_logging.gemspec' + - "grape_logging.gemspec" # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). @@ -441,7 +396,7 @@ Style/RedundantPercentQ: # SupportedStyles: implicit, explicit Style/RescueStandardError: Exclude: - - 'lib/grape_logging/loggers/response.rb' + - "lib/grape_logging/loggers/response.rb" # Offense count: 4 # This cop supports unsafe autocorrection (--autocorrect-all). @@ -449,14 +404,13 @@ Style/RescueStandardError: # AllowedMethods: present?, blank?, presence, try, try! Style/SafeNavigation: Exclude: - - 'claude-scratchpad/cleaner_parameter_filter.rb' - - 'lib/grape_logging/formatters/rails.rb' + - "lib/grape_logging/formatters/rails.rb" # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Style/SlicingWithRange: Exclude: - - 'lib/grape_logging/loggers/request_headers.rb' + - "lib/grape_logging/loggers/request_headers.rb" # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). @@ -464,16 +418,16 @@ Style/SlicingWithRange: # SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names Style/SpecialGlobalVars: Exclude: - - 'spec/spec_helper.rb' + - "spec/spec_helper.rb" # Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Mode. Style/StringConcatenation: Exclude: - - 'lib/grape_logging/formatters/json.rb' - - 'lib/grape_logging/formatters/lograge.rb' - - 'lib/grape_logging/formatters/logstash.rb' + - "lib/grape_logging/formatters/json.rb" + - "lib/grape_logging/formatters/lograge.rb" + - "lib/grape_logging/formatters/logstash.rb" # Offense count: 33 # This cop supports safe autocorrection (--autocorrect). @@ -481,15 +435,15 @@ Style/StringConcatenation: # SupportedStyles: single_quotes, double_quotes Style/StringLiterals: Exclude: - - 'grape_logging.gemspec' - - 'lib/grape_logging/formatters/rails.rb' - - 'lib/grape_logging/loggers/client_env.rb' - - 'lib/grape_logging/util/parameter_filter.rb' - - 'spec/lib/grape_logging/formatters/rails_spec.rb' - - 'spec/lib/grape_logging/loggers/client_env_spec.rb' - - 'spec/lib/grape_logging/loggers/request_headers_spec.rb' - - 'spec/lib/grape_logging/loggers/response_spec.rb' - - 'spec/lib/grape_logging/middleware/request_logger_spec.rb' + - "grape_logging.gemspec" + - "lib/grape_logging/formatters/rails.rb" + - "lib/grape_logging/loggers/client_env.rb" + - "lib/grape_logging/util/parameter_filter.rb" + - "spec/lib/grape_logging/formatters/rails_spec.rb" + - "spec/lib/grape_logging/loggers/client_env_spec.rb" + - "spec/lib/grape_logging/loggers/request_headers_spec.rb" + - "spec/lib/grape_logging/loggers/response_spec.rb" + - "spec/lib/grape_logging/middleware/request_logger_spec.rb" # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). @@ -497,7 +451,7 @@ Style/StringLiterals: # SupportedStyles: single_quotes, double_quotes Style/StringLiteralsInInterpolation: Exclude: - - 'lib/grape_logging/formatters/rails.rb' + - "lib/grape_logging/formatters/rails.rb" # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). @@ -505,7 +459,7 @@ Style/StringLiteralsInInterpolation: # AllowedMethods: define_method Style/SymbolProc: Exclude: - - 'lib/grape_logging/util/parameter_filter.rb' + - "lib/grape_logging/util/parameter_filter.rb" # Offense count: 7 # This cop supports safe autocorrection (--autocorrect). @@ -513,14 +467,14 @@ Style/SymbolProc: # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma Style/TrailingCommaInHashLiteral: Exclude: - - 'spec/lib/grape_logging/loggers/filter_parameters_spec.rb' - - 'spec/lib/grape_logging/loggers/response_spec.rb' + - "spec/lib/grape_logging/loggers/filter_parameters_spec.rb" + - "spec/lib/grape_logging/loggers/response_spec.rb" # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Style/ZeroLengthPredicate: Exclude: - - 'lib/grape_logging/formatters/rails.rb' + - "lib/grape_logging/formatters/rails.rb" # Offense count: 3 # This cop supports safe autocorrection (--autocorrect). From d51a1db42c293ebd89b08aa54508cd692f1b8c65 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Mon, 30 Jun 2025 09:38:27 -0700 Subject: [PATCH 3/8] Specify files explicity in rubocop rake task --- Rakefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 7e9ea69..2d83557 100644 --- a/Rakefile +++ b/Rakefile @@ -7,6 +7,8 @@ RSpec::Core::RakeTask.new(:spec) do |spec| spec.pattern = FileList['spec/**/*_spec.rb'] end -RuboCop::RakeTask.new(:rubocop) +RuboCop::RakeTask.new(:rubocop) do |t| + t.patterns = ['lib/**/*.rb', 'spec/**/*.rb', 'Rakefile', 'Gemfile', 'grape_logging.gemspec'] +end task default: %i[spec rubocop] From 8dfd1e833225ecdf2e7fc7e36945a6f7ff11bd77 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Mon, 30 Jun 2025 09:41:12 -0700 Subject: [PATCH 4/8] Pin rubocop version to 1.77.0 --- grape_logging.gemspec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grape_logging.gemspec b/grape_logging.gemspec index 18b9da0..7831b97 100644 --- a/grape_logging.gemspec +++ b/grape_logging.gemspec @@ -23,5 +23,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.3' spec.add_development_dependency 'rspec', '~> 3.5' - spec.add_development_dependency 'rubocop' + + # This is pinned to an exact version otherwise we can't know which rules + # are in play at any given time in different environments. + spec.add_development_dependency 'rubocop', '1.77.0' end From 0d738e4e7e7c069d2a4c949d09666ee30c647c54 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Wed, 9 Jul 2025 16:54:59 -0700 Subject: [PATCH 5/8] Prepare for 2.0.0 release (#89) * Add a changelog * Add release and contributor docs based on grape-active_model_serializers (needs more work) * Rename changelog to look like it's the 80s * Tweak releasing doc * Automate and document github releases * RIP hash rocket --- CHANGELOG.md | 194 ++++++++++++++++++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 110 +++++++++++++++++++++++++++ README.md | 8 +- RELEASING.md | 111 +++++++++++++++++++++++++++ Rakefile | 29 ++++++++ 5 files changed, 447 insertions(+), 5 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 CONTRIBUTING.md create mode 100644 RELEASING.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..16fc96d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,194 @@ +# Changelog + +## [2.0.0] - 2025-06-28 + +### Changed +- **BREAKING**: Updated to support Grape 2.1 and Rack 3.1 +- Minimum supported Ruby version is now 3.0 +- Replaced Travis CI with GitHub Actions for continuous integration +- Updated all README examples to use `insert_before` instead of `use` for proper middleware placement + +### Fixed +- Fixed LoggerReporter to clone the logger parameter to prevent shared state issues (#77) +- Fixed view time precision issue by rounding to 2 decimal places +- Fixed invalid byte sequence handling for parameter keys by properly managing string encodings (#54) +- Fixed various typos in code comments and spec descriptions (#87) +- Fixed specs to work with Ruby 3.4's hash inspect format changes + +### Documentation +- Clarified middleware placement requirements in README - must be inserted before Grape::Middleware::Error (#74) +- Added gem version badge to README + +[2.0.0]: https://github.com/aserafin/grape_logging/compare/v1.8.4...v2.0.0 + +## [1.8.4] - 2021-10-29 + +### Fixed +- Rails 6 compatibility improvements +- Various bug fixes and dependency updates + +[1.8.4]: https://github.com/aserafin/grape_logging/compare/v1.8.3...v1.8.4 + +## [1.8.3] - 2020-02-27 + +### Fixed +- Performance improvements +- Bug fixes for edge cases + +[1.8.3]: https://github.com/aserafin/grape_logging/compare/v1.8.2...v1.8.3 + +## [1.8.2] - 2019-10-08 + +### Fixed +- Thread safety improvements +- Minor bug fixes + +Note: This version was tagged as "v.1.8.2" (with extra dot) + +[1.8.2]: https://github.com/aserafin/grape_logging/compare/v1.8.1...v.1.8.2 + +## [1.8.1] - 2019-08-07 + +### Fixed +- Bug fixes for parameter filtering +- Improved error handling + +[1.8.1]: https://github.com/aserafin/grape_logging/compare/v1.8.0...v1.8.1 + +## [1.8.0] - 2019-05-30 + +### Added +- Rails formatter for better Rails integration +- Improved Rails instrumentation support + +[1.8.0]: https://github.com/aserafin/grape_logging/compare/v1.7.0...v1.8.0 + +## [1.7.0] - 2017-11-09 + +### Added +- Logstash formatter for ELK stack integration +- Enhanced JSON formatting options + +[1.7.0]: https://github.com/aserafin/grape_logging/compare/v1.6.0...v1.7.0 + +## [1.6.0] - 2017-07-20 + +### Added +- MultiIO support for logging to multiple destinations simultaneously +- Can now log to both file and STDOUT + +[1.6.0]: https://github.com/aserafin/grape_logging/compare/v1.5.0...v1.6.0 + +## [1.5.0] - 2017-06-15 + +### Added +- Configurable log levels +- Better control over logging verbosity + +[1.5.0]: https://github.com/aserafin/grape_logging/compare/v1.4.0...v1.5.0 + +## [1.4.0] - 2017-01-12 + +### Added +- FilterParameters logger for sensitive parameter filtering +- Automatic Rails filter_parameters integration when available + +[1.4.0]: https://github.com/aserafin/grape_logging/compare/v1.3.0...v1.4.0 + +## [1.3.0] - 2016-12-08 + +### Added +- RequestHeaders logger for logging HTTP request headers +- ClientEnv logger for logging client IP and user agent + +[1.3.0]: https://github.com/aserafin/grape_logging/compare/v1.2.1...v1.3.0 + +## [1.2.1] - 2016-04-14 + +### Added +- JSON formatter for structured logging +- Rails instrumentation support via ActiveSupport::Notifications + +### Fixed +- Parameter handling improvements + +[1.2.1]: https://github.com/aserafin/grape_logging/compare/v1.2.0...v1.2.1 + +## [1.2.0] - 2016-01-21 + +### Added +- Response logger for logging response details +- Improved parameter logging + +### Changed +- Better integration with Grape middleware stack + +[1.2.0]: https://github.com/aserafin/grape_logging/compare/v1.1.3...v1.2.0 + +## [1.1.3] - 2015-12-03 + +### Fixed +- Bug fixes for Grape 0.14 compatibility +- Improved error handling + +[1.1.3]: https://github.com/aserafin/grape_logging/compare/v1.1.2...v1.1.3 + +## [1.1.2] - 2015-11-19 + +### Fixed +- Performance optimizations +- Minor bug fixes + +[1.1.2]: https://github.com/aserafin/grape_logging/compare/v1.1.1...v1.1.2 + +## [1.1.1] - 2015-11-12 + +### Fixed +- Critical bug fix for middleware initialization + +Note: This version was tagged as "v.1.1.1" (with extra dot) + +[1.1.1]: https://github.com/aserafin/grape_logging/compare/v1.1.0...v.1.1.1 + +## [1.1.0] - 2015-11-09 + +### Added +- Pluggable logger architecture +- Support for custom loggers via include option +- Base logger class for extending functionality + +### Changed +- Refactored middleware for better extensibility + +[1.1.0]: https://github.com/aserafin/grape_logging/compare/v1.0.3...v1.1.0 + +## [1.0.3] - 2015-11-05 + +### Fixed +- Compatibility fixes for different Grape versions +- Bug fixes + +[1.0.3]: https://github.com/aserafin/grape_logging/compare/v1.0.2...v1.0.3 + +## [1.0.2] - 2015-10-29 + +### Fixed +- Minor bug fixes and improvements + +[1.0.2]: https://github.com/aserafin/grape_logging/compare/v1.0.1...v1.0.2 + +## [1.0.1] - 2015-10-22 + +### Fixed +- Initial bug fixes after 1.0 release + +[1.0.1]: https://github.com/aserafin/grape_logging/compare/v1.0...v1.0.1 + +## [1.0] - 2015-10-15 + +### Added +- Initial release +- Request logging middleware for Grape APIs +- Basic request/response logging +- Configurable formatters +- Time tracking (total, db, view) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..549bc8a --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,110 @@ +# Contributing to grape_logging + +This project is work of many contributors. You're encouraged to submit pull requests, propose features and discuss issues. + +## Fork the Project + +Fork the project on Github and check out your copy. + +``` +git clone https://github.com/contributor/grape_logging.git +cd grape_logging +git remote add upstream https://github.com/aserafin/grape_logging.git +``` + +## Create a Topic Branch + +Make sure your fork is up-to-date and create a topic branch for your feature or bug fix. + +``` +git checkout master +git pull upstream master +git checkout -b my-feature-branch +``` + +## Bundle Install and Test + +Ensure that you can build the project and run tests. + +``` +bundle install +bundle exec rake +``` + +## Write Tests + +Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to the spec directory. + +## Write Code + +Implement your feature or bug fix. + +Ruby style is enforced with RuboCop. Run `bundle exec rubocop` and fix any style issues highlighted. + +Make sure that `bundle exec rake` completes without errors. + +## Write Documentation + +Document any external behavior in the README.md. + +## Update Changelog + +Add a line to Changelog.md under *Next Release*. Make it look like every other line, including your name and link to your Github account. + +## Commit Changes + +Make sure git knows your name and email address: + +``` +git config --global user.name "Your Name" +git config --global user.email "contributor@example.com" +``` + +Writing good commit logs is important. A commit log should describe what changed and why. + +``` +git add ... +git commit +``` + +## Push + +``` +git push origin my-feature-branch +``` + +## Make a Pull Request + +Go to https://github.com/contributor/grape_logging and select your feature branch. Click the 'Pull Request' button and fill out the form. + +We'll try to review pull requests within a few days but as this is maintained by a small group of volunteers there is no guarantee that we'll look at it within any time frame, or at all. There's no maintenance guarantee. + +## Discuss and Update + +You may get feedback or requests for changes to your pull request. This is a big part of the submission process so don't be discouraged! + +Some things that will increase the chance that your pull request is accepted: + +- Write tests. +- Follow the Ruby style guide. +- Write a good commit message. + +If you'd like to discuss a feature or bug fix before starting work, please [create an issue](https://github.com/aserafin/grape_logging/issues) first. This helps ensure your contribution aligns with the project's direction and avoids duplicate efforts. + +## Rebase + +If you've been working on a change for a while, rebase with upstream/master. + +``` +git fetch upstream +git rebase upstream/master +git push origin my-feature-branch -f +``` + +## Be Patient + +It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang in there! + +## Thank You + +Please do know that we really appreciate and value your time and work. We love you, really. diff --git a/README.md b/README.md index 5babab7..05a7251 100644 --- a/README.md +++ b/README.md @@ -209,10 +209,8 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). +For maintainers releasing a new version, please see [Releasing.md](Releasing.md). + ## Contributing -1. Fork it ( https://github.com/aserafin/grape_logging/fork ) -2. Create your feature branch (`git checkout -b my-new-feature`) -3. Commit your changes (`git commit -am 'Add some feature'`) -4. Push to the branch (`git push origin my-new-feature`) -5. Create a new Pull Request +See [Contributing.md](Contributing.md). diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 0000000..45646bf --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,111 @@ +# Releasing grape_logging + +There're no particular rules about when to release grape_logging. Release bug fixes frequently, features not so frequently and breaking API changes rarely. + +### Pre-flight Checks + +Run tests, check that all tests succeed locally. + +``` +bundle install +rake +``` + +Check that the last build succeeded in [GitHub Actions](https://github.com/aserafin/grape_logging/actions) for all supported platforms. + +### Update Changelog + +Change "Next Release" in [CHANGELOG.md](https://github.com/aserafin/grape_logging/blob/master/CHANGELOG.md) to the new version and date: + +``` +## [1.8.5] - 2024-06-28 + +### Changed +- Description of changes + +### Fixed +- Description of fixes + +### Added +- Description of additions + +[1.8.5]: https://github.com/aserafin/grape_logging/compare/v1.8.4...v1.8.5 +``` + +Remove the line with "Your contribution here.", since there will be no more contributions to this release. + +Only include the sections (Changed, Fixed, Added, etc.) that have actual changes. + +Commit your changes. + +```shell +git add CHANGELOG.md lib/grape_logging/version.rb +git commit -m "Preparing for release, 1.8.5." +git push github master +``` + +### Release on RubyGems and GitHub + +#### Option 1: Automated (Recommended) + +Use the combined task that releases the gem and creates a GitHub release: + +```shell +rake github_release +``` + +This will: +1. Build and push the gem to RubyGems +2. Create and push the git tag +3. Create a GitHub release with auto-generated changelog + +#### Option 2: Manual + +First, release the gem: + +```shell +rake release +``` + +Output will look something like: +``` +grape_logging 1.8.5 built to pkg/grape_logging-1.8.5.gem. +Tagged v1.8.5. +Pushed git commits and tags. +Pushed grape_logging 1.8.5 to rubygems.org. +``` + +Then create the GitHub release on the web or using `gh`: + +``` +gh release create v1.8.5 --generate-notes --verify-tag +``` + +This uses GitHub's automatic changelog generation feature to create release notes from merged pull requests and commits since the last release. + +### Prepare for the Next Version + +Modify `lib/grape_logging/version.rb`, increment the version number (eg. change `1.8.5` to `1.8.6`). + +```ruby +module GrapeLogging + VERSION = '1.8.6'.freeze +end +``` + +Add the next release to [CHANGELOG.md](https://github.com/aserafin/grape_logging/blob/master/CHANGELOG.md). + +``` +## [Next Release] + +### Changed or Fixed or Added +* Your contribution here. +``` + +Commit your changes. + +``` +git add CHANGELOG.md lib/grape_logging/version.rb +git commit -m "Bump version to 1.8.6." +git push github master +``` diff --git a/Rakefile b/Rakefile index 4c774a2..2efaf1b 100644 --- a/Rakefile +++ b/Rakefile @@ -4,3 +4,32 @@ require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) task default: :spec + +desc 'Release gem and create GitHub release' +task github_release: :release do + require 'grape_logging/version' + + version = "v#{GrapeLogging::VERSION}" + + # Check if gh CLI is available + unless system('which gh > /dev/null 2>&1') + puts "\n⚠️ GitHub CLI (gh) not found" + puts "To create a GitHub release with auto-generated changelog, install gh:" + puts " brew install gh # macOS with Homebrew" + puts " # or visit: https://github.com/cli/cli#installation" + puts "\nYou can manually create the release with:" + puts " gh release create v#{GrapeLogging::VERSION} --generate-notes" + next + end + + # Create GitHub release + puts "\nCreating GitHub release #{version}..." + + if system('gh', 'release', 'create', version, '--generate-notes', '--verify-tag') + puts "✅ GitHub release #{version} created successfully" + else + puts "❌ Failed to create GitHub release" + puts "You can manually create it with:" + puts " gh release create '#{version}' --generate-notes --verify-tag" + end +end From 362dd0a92ed33a3e2f958c8d89db5c0b6271885e Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Wed, 9 Jul 2025 16:55:57 -0700 Subject: [PATCH 6/8] Bump version to 2.0.0 --- lib/grape_logging/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/grape_logging/version.rb b/lib/grape_logging/version.rb index 1dd04f6..fad54bc 100644 --- a/lib/grape_logging/version.rb +++ b/lib/grape_logging/version.rb @@ -1,3 +1,3 @@ module GrapeLogging - VERSION = '1.8.4' + VERSION = '2.0.0' end From c19b1d37322fd13c97a232b2fe04d4ac2b619b3b Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Wed, 9 Jul 2025 16:57:51 -0700 Subject: [PATCH 7/8] Bump version to 2.0.1 --- CHANGELOG.md | 9 ++++++++- lib/grape_logging/version.rb | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16fc96d..c489fdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ # Changelog -## [2.0.0] - 2025-06-28 +## [2.0.1] - Unreleased + +### Changed or Fixed or Added +* Your contribution here. + +[2.0.1]: https://github.com/aserafin/grape_logging/compare/v2.0.0...master + +## [2.0.0] - 2025-07-09 ### Changed - **BREAKING**: Updated to support Grape 2.1 and Rack 3.1 diff --git a/lib/grape_logging/version.rb b/lib/grape_logging/version.rb index fad54bc..162c7cf 100644 --- a/lib/grape_logging/version.rb +++ b/lib/grape_logging/version.rb @@ -1,3 +1,3 @@ module GrapeLogging - VERSION = '2.0.0' + VERSION = '2.0.1' end From a4f6088a17edbf3d3a77e412852a368f4e6f5b27 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Wed, 9 Jul 2025 16:58:44 -0700 Subject: [PATCH 8/8] Remove remote name from releasing doc --- RELEASING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index 45646bf..5e3f805 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -41,7 +41,7 @@ Commit your changes. ```shell git add CHANGELOG.md lib/grape_logging/version.rb git commit -m "Preparing for release, 1.8.5." -git push github master +git push ``` ### Release on RubyGems and GitHub @@ -107,5 +107,5 @@ Commit your changes. ``` git add CHANGELOG.md lib/grape_logging/version.rb git commit -m "Bump version to 1.8.6." -git push github master +git push ```