Skip to content

Conversation

@cardmagic
Copy link
Owner

Summary

Add RuboCop with rubocop-minitest for consistent code style and automated linting in CI.

Changes

  • Add rubocop and rubocop-minitest gems
  • Create .rubocop.yml with project-specific configuration
  • Auto-correct 151 style offenses
  • Add respond_to_missing? to Bayes class (fixes RuboCop warning)
  • Add lint job to CI workflow (runs on Ruby 3.3)

Configuration Highlights

  • Exclude legacy bin/ and install.rb files
  • Exclude complex algorithm files from metrics checks (SVD, LSI)
  • Single quotes for strings
  • Minitest best practices enabled

Files Excluded from Metrics

Some files contain complex mathematical algorithms that exceed standard metrics. These are tracked in #60 for future refactoring:

  • lib/classifier/extensions/vector.rb (SVD algorithm)
  • lib/classifier/lsi/content_node.rb (vector operations)
  • lib/classifier/lsi.rb (index building)

CI

New lint job runs RuboCop on every push/PR.

Fixes #56

@cardmagic cardmagic requested a review from Copilot December 27, 2025 06:48
@cardmagic cardmagic self-assigned this Dec 27, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds RuboCop with rubocop-minitest for consistent code style and automated linting in CI. The changes include adding RuboCop gems, configuring style rules, auto-correcting 151 style offenses across test and library files, and adding a lint job to the CI workflow.

Key changes:

  • Added RuboCop configuration excluding legacy files and complex algorithms from metrics checks
  • Auto-corrected style offenses including string literals, assertion styles, and code formatting
  • Added respond_to_missing? method to Bayes class to complement method_missing

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Gemfile Added rubocop and rubocop-minitest gems to development group
.rubocop.yml Created RuboCop configuration with project-specific rules and exclusions
.github/workflows/ruby.yml Added lint job to CI workflow running RuboCop on Ruby 3.3
lib/classifier/bayes.rb Added respond_to_missing? method and optimized classify method
lib/classifier/lsi.rb Updated block parameter syntax and fixed operator precedence in array slicing
lib/classifier/extensions/word_hash.rb Fixed escaped character in string literal
lib/classifier/extensions/vector.rb Updated block parameter syntax and fixed operator precedence
test/test_helper.rb Changed $: to $LOAD_PATH and updated string concatenation
test/lsi/lsi_test.rb Replaced assert/refute with predicate assertions and assert_operator
test/extensions/word_hash_test.rb Changed double quotes to single quotes and reordered assert arguments
test/bayes/bayesian_test.rb Updated assertion styles and added blank lines for readability

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Add RuboCop with rubocop-minitest for consistent code style:

- Configure .rubocop.yml with project-specific rules
- Exclude legacy bin/ and install.rb files
- Allow complexity in mathematical algorithms (SVD, LSI)
- Auto-correct 151 style offenses
- Add respond_to_missing? to Bayes class
- Add lint job to CI workflow

Style improvements applied:
- Consistent single quotes for strings
- Proper spacing and indentation
- Modern Ruby idioms (anonymous block forwarding)
- Minitest assertion best practices

Fixes #56
@cardmagic cardmagic merged commit ba21e6f into master Dec 27, 2025
5 checks passed
@cardmagic cardmagic deleted the chore/add-rubocop branch December 27, 2025 06:52
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.

Add RuboCop for code standardization

2 participants