-
Notifications
You must be signed in to change notification settings - Fork 664
V1.0.0 #1043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V1.0.0 #1043
Conversation
…v access in specs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @chemica, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request represents a significant update to the project, effectively forking the original annotate gem to provide compatibility with modern Ruby (specifically 3.2.2+) and Rails (8.0.0+). The changes encompass updating core dependencies, modernizing the codebase to align with newer Ruby features and best practices, and cleaning up code style through extensive RuboCop configuration updates. The gem name has also been changed to annot8 to reflect its status as a fork aimed at supporting these newer versions.
Highlights
- Gem Fork & Renaming: The project is now a fork of the original
annotategem and has been renamed toannot8. - Dependency Updates: Updated
activerecordrequirement to support Rails 8.0.0+ and set the required Ruby version to 3.2.2+. Addedjson,ruby-lsp, andraccgems. Removed version constraints fromrubocopandrubocop-rspecto allow using the latest versions. - RuboCop Modernization: Updated RuboCop configuration (
.rubocop.yml,.rubocop_todo.yml), enabling many previously disabled cops and enforcing stricter code style, including enablingStyle/FrozenStringLiteralCommentand updating target Ruby version. - Ruby 3.2+ Compatibility: Addressed compatibility issues with Ruby 3.2+, such as replacing
File.exists?withFile.exist?(via a patch), using__dir__instead ofFile.dirname(__FILE__), and usingENV.fetchfor accessing environment variables safely. - Code Style Improvements: Replaced usages of
$stderr.putswithwarnand updated various string formatting (sprintftoformat) and regex literal usages (/.../to%r{...}) for better style and compatibility.
Changelog
Click here to see the changelog
- .gitignore
- Removed
.ruby-*and/Gemfile.lockfrom ignored files.
- Removed
- .rubocop.yml
- Changed
requiretopluginsfor RuboCop extensions. - Added
TargetRubyVersion: 3.2.2toAllCops. - Enabled
Style/FrozenStringLiteralComment.
- Changed
- .rubocop_todo.yml
- Significantly reduced the number of excluded/disabled cops, indicating code style improvements.
- Updated the RuboCop version comment to 1.75.8.
- Adjusted configurations for various cops (e.g.,
Layout/ExtraSpacing,Metrics/AbcSize,Metrics/MethodLength,RSpec/ExampleLength,RSpec/NestedGroups).
- .ruby-version
- Added Ruby version
3.2.2.
- Added Ruby version
- Gemfile
- Updated
activerecorddependency to>= 8.0.0,< 9. - Added
json,racc, andruby-lspgems. - Removed version constraints from
rubocopandrubocop-rspec. - Removed
ruby_depgem. - Added
frozen_string_literal: truecomment.
- Updated
- Gemfile.lock
- Added a new
Gemfile.lockfile reflecting the updated dependencies for Ruby 3.2.2 and Rails 8.0.2.
- Added a new
- Guardfile
- Added
frozen_string_literal: truecomment. - Added
all_on_start: trueoption to therspecguard. - Changed some block syntax to use
do...end.
- Added
- README.md
- Added a note indicating this is a fork for Rails 8 and Ruby 3.2.2+.
- Changed gem name references from
annotatetoannot8. - Updated repository URL references from
ctran/annotate_modelstochemica/annotate_models.
- Rakefile
- Added
frozen_string_literal: truecomment. - Replaced
$stderr.putswithwarn. - Updated regex delimiters from
/.../to%r{...}for path matching. - Slightly adjusted the logic for adding runtime dependencies in the
gem:gemspectask.
- Added
- annotate.gemspec
- Changed the gem name from
annotatetoannot8. - Updated the required Ruby version to
>= 3.2.2. - Updated authors and email information.
- Updated the description to mention the fork and compatibility with Rails 8 and Ruby 3.2.2+.
- Updated homepage and source code URIs to the
chemicarepository. - Updated
activerecorddependency to>= 8.0.0,< 9. - Added
rubygems_mfa_requiredmetadata.
- Changed the gem name from
- bin/annotate
- Added
frozen_string_literal: truecomment. - Simplified the
abortcondition. - Replaced
File.expand_path(File.dirname __FILE__)with__dir__. - Changed
ENV['is_rake']access toENV.fetch('is_rake', nil).
- Added
- lib/annotate.rb
- Added
frozen_string_literal: truecomment. - Added
rubocop:disable Metrics/ModuleLengthcomment. - Changed
ENV[...]access toENV.fetch(..., nil). - Simplified conditional assignments for options.
- Removed
.sortfromDir.globiteration. - Changed bare
rescuetorescue StandardError. - Replaced
$stderr.putswithwarn.
- Added
- lib/annotate/active_record_patch.rb
- Added
frozen_string_literal: truecomment.
- Added
- lib/annotate/annotate_models.rb
- Added
frozen_string_literal: truecomment. - Removed
.freezefrom constants. - Changed
MATCHED_TYPES,NO_LIMIT_COL_TYPES,NO_DEFAULT_COL_TYPESto use array literals directly. - Changed
MAGIC_COMMENT_MATCHERto use a literal regex. - Added
skip_subdirectory_model_loadas anattr_writer. - Updated regex delimiter from
/.../to%r{...}. - Used
String.new('')for creating mutable strings. - Used
formatinstead ofsprintffor string formatting. - Used
to_hfor hash conversion. - Updated
get_attributeslogic for primary key and simple indexes. - Changed bare
rescuetorescue StandardError. - Replaced
$stderr.putswithwarn. - Simplified conditional assignments.
- Adjusted array slicing in
get_model_class.
- Added
- lib/annotate/annotate_models/file_patterns.rb
- Added
frozen_string_literal: truecomment.
- Added
- lib/annotate/annotate_routes.rb
- Added
frozen_string_literal: truecomment. - Changed
require_relativepaths to use relative paths without./. - Changed
remove_annotationsmethod signature. - Changed
header = header << ''toheader <<= ''.
- Added
- lib/annotate/annotate_routes/header_generator.rb
- Added
frozen_string_literal: truecomment. - Removed
.freezefrom constants. - Changed
require_relativepath. - Changed
rake routessplit delimiter. - Changed regex delimiter from
/.../to%r{...}. - Changed array slice
[1..-1]to[1..]. - Used
formatinstead ofsprintf.
- Added
- lib/annotate/annotate_routes/helpers.rb
- Added
frozen_string_literal: truecomment. - Removed
.freezefrom constant. - Changed split delimiter.
- Simplified return value in
real_content_and_header_position.
- Added
- lib/annotate/constants.rb
- Added
frozen_string_literal: truecomment. - Removed
.freezefrom constant regex. - Simplified array literals.
- Added
- lib/annotate/helpers.rb
- Added
frozen_string_literal: truecomment. - Changed
ENV[...]access toENV.fetch(..., nil).
- Added
- lib/annotate/parser.rb
- Added
frozen_string_literal: truecomment. - Removed
Metrics/ClassLengthdisable comment. - Simplified array literal.
- Added
- lib/annotate/tasks.rb
- Added
frozen_string_literal: truecomment.
- Added
- lib/annotate/version.rb
- Added
frozen_string_literal: truecomment. - Updated version to '1.0.0'.
- Added
- lib/generators/annotate/install_generator.rb
- Added
frozen_string_literal: truecomment.
- Added
- lib/generators/annotate/templates/auto_annotate_models.rake
- Added
frozen_string_literal: truecomment. - Updated default options hash syntax.
- Added
- lib/tasks/annotate_models.rake
- Added
frozen_string_literal: truecomment. - Changed
File.expand_path(File.dirname(File.dirname(__FILE__)))toFile.expand_path(File.dirname(__FILE__, 2)). - Changed
ENV[...]access toENV.fetch(..., nil). - Updated default options hash syntax.
- Added
- lib/tasks/annotate_models_migrate.rake
- Added
frozen_string_literal: truecomment. - Changed array literal.
- Slightly adjusted the logic in
update_annotations.
- Added
- lib/tasks/annotate_routes.rake
- Added
frozen_string_literal: truecomment. - Changed
File.expand_path(File.dirname(File.dirname(__FILE__)))toFile.expand_path(File.dirname(__FILE__, 2)). - Changed
ENV[...]access toENV.fetch(..., nil).
- Added
- spec/lib/annotate/annotate_models/file_patterns_spec.rb
- Added
frozen_string_literal: truecomment. - Changed
subjecttolet. - Updated expectations to use the new
letvariable.
- Added
- spec/lib/annotate/annotate_models_spec.rb
- Added
frozen_string_literal: truecomment. - Changed
doubletoinstance_doublewhere appropriate for better mocking. - Updated mock methods to align with
instance_doubleusage. - Changed
subjecttoletin various contexts. - Updated expectations to use the new
letvariables. - Changed
before :eachtobeforeandafter :eachtoafter. - Changed
expect(...).to_not receivetoexpect(...).not_to receive. - Updated tests for the
frozenoption to correctly raiseSystemExitwith the expected message. - Updated
get_model_classtests to reflect changes in subdirectory loading logic.
- Added
- spec/lib/annotate/annotate_routes_spec.rb
- Added
frozen_string_literal: truecomment. - Removed
.freezefrom constants. - Changed
before :eachtobefore. - Adjusted markdown header spacing in expected output.
- Added
- spec/lib/annotate/helpers_spec.rb
- Added
frozen_string_literal: truecomment. - Changed
allow(ENV).to receive(:[])toallow(ENV).to receive(:fetch)for accessing environment variables in tests.
- Added
- spec/lib/annotate/parser_spec.rb
- Added
frozen_string_literal: truecomment. - Changed
before(:example)tobefore. - Changed
ENV[...]access toENV.fetch(..., nil)in expectations.
- Added
- spec/lib/annotate_spec.rb
- Added
frozen_string_literal: truecomment.
- Added
- spec/lib/tasks/annotate_models_migrate_spec.rb
- Added
frozen_string_literal: truecomment. - Changed array literal.
- Added
- spec/lib/tasks/annotate_models_spec.rb
- Added
frozen_string_literal: truecomment. - Removed
RSpec/DescribeClassdisable comment.
- Added
- spec/spec_helper.rb
- Added
frozen_string_literal: truecomment. - Required
support/file_exists_patch.
- Added
- spec/support/file_exists_patch.rb
- Added a new file to monkey patch
File.exists?for compatibility with Ruby 3.2+.
- Added a new file to monkey patch
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Old gems gather dust,
New versions bring features bright,
Codebase shines anew.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a significant version bump to V1.0.0, likely reflecting the substantial updates for Rails 8 and Ruby 3.2.2+ compatibility. The changes include updates to dependencies, RuboCop configuration, and various code style improvements across the codebase, such as adopting frozen string literals and more modern Ruby syntax.
Overall, the updates are positive and move the project towards better practices and compatibility with newer environments. However, there are a couple of areas that warrant further discussion to ensure code quality and prevent potential issues.
Summary of Findings
- Broad RSpec Exclusions in RuboCop TODO: Several RSpec-related RuboCop cops have been configured with broad
spec/**/*exclusions in.rubocop_todo.yml. This might mask potential issues in the test suite and could affect long-term test maintainability. - Removal of Sort in Eager Loading Path: In
lib/annotate.rb, the.sortmethod was removed from aDir.globcall that processeseager_load_pathsfor older Rails versions. This could potentially alter file loading order, which might be significant if there are inter-dependencies sensitive to load order.
Merge Readiness
This pull request brings important updates for compatibility with modern Rails and Ruby versions. The code is largely improved with style updates and dependency management.
However, there are two medium-severity concerns identified:
- The broad exclusions for RSpec cops in the RuboCop configuration might hinder test quality and maintainability.
- The removal of sorting when processing eager load paths could potentially affect file loading order in older Rails applications.
I recommend addressing these points before merging to ensure the stability and quality of the codebase. As an AI, I am not authorized to approve pull requests; please ensure further review and approval from other maintainers.
| - 'spec/**/*' | ||
|
|
||
| # Offense count: 10 | ||
| # Cop supports --auto-correct. | ||
| # Configuration parameters: EnforcedStyle. | ||
| # SupportedStyles: implicit, each, example | ||
| RSpec/HookArgument: | ||
| RSpec/ExpectInHook: | ||
| Exclude: | ||
| - 'spec/lib/annotate/annotate_models_spec.rb' | ||
| - 'spec/lib/annotate/annotate_routes_spec.rb' | ||
| - 'spec/lib/annotate/parser_spec.rb' | ||
|
|
||
| # Offense count: 1 | ||
| # Cop supports --auto-correct. | ||
| RSpec/HooksBeforeExamples: | ||
| Exclude: | ||
| - 'spec/lib/annotate/annotate_models_spec.rb' | ||
|
|
||
| # Offense count: 78 | ||
| # Cop supports --auto-correct. | ||
| # Configuration parameters: EnforcedStyle. | ||
| # SupportedStyles: single_line_only, single_statement_only, disallow | ||
| RSpec/ImplicitSubject: | ||
| Exclude: | ||
| - 'spec/lib/annotate/annotate_models/file_patterns_spec.rb' | ||
| - 'spec/lib/annotate/annotate_models_spec.rb' | ||
| - 'spec/lib/annotate/helpers_spec.rb' | ||
|
|
||
| # Offense count: 51 | ||
| # Configuration parameters: AssignmentOnly. | ||
| RSpec/InstanceVariable: | ||
| Exclude: | ||
| - 'spec/lib/annotate/annotate_models_spec.rb' | ||
|
|
||
| # Offense count: 4 | ||
| # Cop supports --auto-correct. | ||
| RSpec/LeadingSubject: | ||
| # Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns. | ||
| RSpec/IndexedLet: | ||
| Exclude: | ||
| - 'spec/lib/annotate/annotate_models_spec.rb' | ||
| - 'spec/lib/annotate/helpers_spec.rb' | ||
|
|
||
| # Offense count: 9 | ||
| # Offense count: 6 | ||
| RSpec/LeakyConstantDeclaration: | ||
| Exclude: | ||
| - 'spec/lib/annotate/annotate_models_spec.rb' | ||
| - 'spec/lib/annotate/annotate_routes_spec.rb' | ||
|
|
||
| # Offense count: 108 | ||
| # Offense count: 109 | ||
| # Configuration parameters: EnforcedStyle. | ||
| # SupportedStyles: have_received, receive | ||
| RSpec/MessageSpies: | ||
| Exclude: | ||
| - 'spec/lib/annotate/annotate_models_spec.rb' | ||
| - 'spec/lib/annotate/annotate_routes_spec.rb' | ||
| - 'spec/lib/annotate/helpers_spec.rb' | ||
| - 'spec/lib/annotate/parser_spec.rb' | ||
| - 'spec/lib/tasks/annotate_models_migrate_spec.rb' | ||
|
|
||
| # Offense count: 36 | ||
| # Offense count: 29 | ||
| RSpec/MultipleExpectations: | ||
| Max: 4 | ||
|
|
||
| # Offense count: 66 | ||
| # Configuration parameters: AllowSubject. | ||
| RSpec/MultipleMemoizedHelpers: | ||
| Max: 9 | ||
|
|
||
| # Offense count: 6 | ||
| # Configuration parameters: IgnoreSharedExamples. | ||
| # Offense count: 5 | ||
| # Configuration parameters: EnforcedStyle, IgnoreSharedExamples. | ||
| # SupportedStyles: always, named_only | ||
| RSpec/NamedSubject: | ||
| Exclude: | ||
| - 'spec/lib/annotate/annotate_models_spec.rb' | ||
| - 'spec/lib/annotate/helpers_spec.rb' | ||
| - 'spec/lib/tasks/annotate_models_migrate_spec.rb' | ||
| - 'spec/**/*' | ||
|
|
||
| # Offense count: 140 | ||
| # Offense count: 39 | ||
| # Configuration parameters: AllowedGroups. | ||
| RSpec/NestedGroups: | ||
| Max: 9 | ||
|
|
||
| # Offense count: 2 | ||
| # Cop supports --auto-correct. | ||
| # Configuration parameters: EnforcedStyle. | ||
| # SupportedStyles: not_to, to_not | ||
| RSpec/NotToNot: | ||
| Exclude: | ||
| - 'spec/lib/annotate/annotate_models_spec.rb' | ||
| - 'spec/lib/annotate/helpers_spec.rb' | ||
| - 'spec/**/*' | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems several RSpec cops (RSpec/ExampleLength, RSpec/NamedSubject, RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers, RSpec/InstanceVariable) now have very broad Exclude patterns like spec/**/*.
While this silences RuboCop warnings, could such broad exclusions potentially hide issues in the test suite or lead to a decline in test code quality over time? Perhaps more targeted exclusions or addressing the underlying RSpec offenses would be beneficial in the long run.
| Rails.configuration.eager_load_paths.each do |load_path| | ||
| matcher = /\A#{Regexp.escape(load_path)}(.*)\.rb\Z/ | ||
| Dir.glob("#{load_path}/**/*.rb").sort.each do |file| | ||
| Dir.glob("#{load_path}/**/*.rb").each do |file| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The .sort call was removed from Dir.glob("#{load_path}/**/*.rb").sort.each during the eager loading process.
Could the order of loading files in Rails.configuration.eager_load_paths be significant, especially for older Rails versions (Rails < 3 as per the conditional)? If there are implicit dependencies based on load order, removing .sort might introduce subtle bugs or change behavior. Was this change tested for potential load order issues?
No description provided.