Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proof of concept separation of departments #1476

Closed
wants to merge 10 commits into from
Closed

Proof of concept separation of departments #1476

wants to merge 10 commits into from

Conversation

pirj
Copy link
Member

@pirj pirj commented Nov 9, 2022

See discussion

馃攷 better viewed without indentation changes

I went too far, as renaming cops is a breaking change:

.rubocop_todo.yml: RSpec/FactoryBot/ConsistentParenthesesStyle has the wrong namespace - should be FactoryBot
.rubocop_todo.yml: RSpec/FactoryBot/CreateList has the wrong namespace - should be FactoryBot
.rubocop_todo.yml: RSpec/FactoryBot/FactoryClassName has the wrong namespace - should be FactoryBot
Error: Ambiguous cop name `RSpec/Rails/HttpStatus` used in /Users/pirj/source/test/.rubocop_todo.yml needs department qualifier. Did you mean Rails/HttpStatus or RSpecRails/HttpStatus?

This way it would be a breaking change. And we could only afford this in 3.0.
But then, when we'll decide to actually extract them, we'd have to release 4.0.
And when RuboCop 2.0 is finally released, and if we decide not to sync our 3.0 and 2.0 with it, we'll have to release 5.0. Just because they will enable their pending cops.

What do you think of such a series of major updates?

Not done

  1. RuboCop::RSpec::FactoryBot::Language is used by both the extracted (lib/rubocop/cop/factory_bot/create_list.rb, lib/rubocop/cop/factory_bot/consistent_parentheses_style.rb) and the remaining lib/rubocop/cop/rspec/factory_bot/syntax_methods.rb cops.

  2. Too lazy to fix one last spec


Before submitting the PR make sure the following are checked:

  • [+] Feature branch is up-to-date with master (if not - rebase it).
  • [-] Squashed related commits together.
  • [-] Added tests.
  • [-] Updated documentation.
  • [-] Added an entry to the CHANGELOG.md if the new code introduces user-observable changes.
  • [+/-] The build (bundle exec rake) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).

@pirj pirj self-assigned this Nov 9, 2022
@pirj pirj added the Discussion label Nov 9, 2022
@@ -12,3 +12,20 @@ changed_parameters:
parameters: IgnoredPatterns
alternative: AllowedPatterns
severity: warning

renamed:
Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -37,7 +35,10 @@

Copy link
Member Author

Choose a reason for hiding this comment

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

require_relative 'rubocop/rspec/factory_bot'

above is needed by both the extracted (RSpec-agnostic) and the remaining (RSpec-specific) FactoryBot cops.

@@ -47,7 +48,7 @@ def replace_nil(config)
end

def reference(cop)
COP_DOC_BASE_URL + cop.sub('RSpec/', '')
Copy link
Member Author

Choose a reason for hiding this comment

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

Any idea why this was needed?

@@ -32,10 +32,7 @@ def initialize(yardoc)
#
# @return [Boolean]
def rspec_cop?
class_documentation? &&
Copy link
Member Author

Choose a reason for hiding this comment

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

Replaced with an argument YARD::Registry.all(:class).

@@ -32,10 +32,7 @@ def initialize(yardoc)
#
# @return [Boolean]
def rspec_cop?
class_documentation? &&
rspec_cop_namespace? &&
Copy link
Member Author

Choose a reason for hiding this comment

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

We only load our classes using a glob, why would we check if it's really ours?

Comment on lines +19 to 20
'{capybara,factory_bot,rspec,rspec-rails}',
'{,capybara,factory_bot,rails}', '*.rb')
Copy link
Member Author

Choose a reason for hiding this comment

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

Not perfect. Could probably be '{capybara,factory_bot,rspec,rspec/capybara,rspec/factory_bot,rspec/rails,rspec-rails}, but it's not platform-independent. Do we care about other platforms (that one with \ file separator!) running our tests?

@pirj pirj mentioned this pull request Dec 11, 2022
3 tasks
@pirj
Copy link
Member Author

pirj commented Dec 11, 2022

I'm closing this one and will make another iteration going further, with putting all the prospective gems in separate directories, with own gemspecs, lib, spec etc.

@pirj pirj closed this Dec 11, 2022
@pirj pirj deleted the split-up branch December 11, 2022 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant