Skip to content

fix: resolve RuboCop Style/OneClassPerFile violations#154

Merged
cardmagic merged 1 commit into
masterfrom
fix/rubocop-one-class-per-file
May 14, 2026
Merged

fix: resolve RuboCop Style/OneClassPerFile violations#154
cardmagic merged 1 commit into
masterfrom
fix/rubocop-one-class-per-file

Conversation

@cardmagic
Copy link
Copy Markdown
Owner

Summary

  • Add Style/OneClassPerFile exclusions for extension files and tests
  • Fix Style/PredicateWithKind offense using all?(Numeric) syntax

Fixes the lint job that's been failing on master since March 2026 due to newer RuboCop versions enforcing Style/OneClassPerFile.

The excluded patterns are legitimate:

  • lib/classifier/extensions/vector.rb - patches stdlib Vector and Matrix classes
  • lib/classifier/lsi.rb - module structure with nested definitions
  • test/**/* - test files commonly group related test classes

Test plan

  • bundle exec rubocop passes locally (47 files, no offenses)

Newer RuboCop versions enforce Style/OneClassPerFile which flags:
- Extension files patching multiple stdlib classes (Vector, Matrix)
- LSI module structure
- Test files with multiple test classes

These are legitimate patterns for this codebase. Add exclusions for
extension files and test directories.

Also fix Style/PredicateWithKind in lsi_test.rb using the preferred
all?(Numeric) syntax.
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 14, 2026

Greptile Summary

This PR fixes a failing lint job by adding targeted Style/OneClassPerFile exclusions in .rubocop.yml and replacing a verbose is_a? block in one test assertion with the idiomatic all?(Numeric) form.

  • .rubocop.yml: New Style/OneClassPerFile cop exclusions follow the same pattern already established for Metrics/* cops in the file; the excluded paths (lib/classifier/extensions/vector.rb, lib/classifier/lsi.rb, test/**/*) are genuinely multi-class files and the broad test glob is consistent with how other cops (Metrics/BlockLength, Security/MarshalLoad) are already scoped.
  • test/lsi/lsi_test.rb: all?(Numeric) uses Enumerable#all?'s pattern-argument form (available since Ruby 2.5, target is 3.1), where Numeric === v is identical to v.is_a?(Numeric), so behaviour is unchanged.

Confidence Score: 5/5

Two-file change: a config exclusion addition and a single-line test assertion rewrite — both safe to merge.

The .rubocop.yml exclusions mirror patterns already present in the file and are scoped to files that genuinely require them. The all?(Numeric) rewrite is a semantically identical transformation on a test-only assertion with no production impact.

No files require special attention.

Important Files Changed

Filename Overview
.rubocop.yml Adds Style/OneClassPerFile exclusions for stdlib-patching extension files and test files, consistent with existing exclusion patterns in the file.
test/lsi/lsi_test.rb Replaces verbose `all? {

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[rubocop run] --> B{File in AllCops Exclude?}
    B -- yes --> Z[Skip file]
    B -- no --> C{Style/OneClassPerFile}
    C --> D{File matches new Exclude?}
    D -- yes: lib/classifier/extensions/vector.rb --> Z
    D -- yes: lib/classifier/lsi.rb --> Z
    D -- yes: test/**/* --> Z
    D -- no --> E[Enforce one class per file]
    E --> F{Violation found?}
    F -- yes --> G[Report offense]
    F -- no --> H[Pass]
Loading

Reviews (1): Last reviewed commit: "fix: resolve RuboCop Style/OneClassPerFi..." | Re-trigger Greptile

@cardmagic cardmagic merged commit 2c223a2 into master May 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant