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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable a few pending cops #1744

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,18 @@ Layout/LineContinuationSpacing:
Enabled: true
Layout/LineEndStringConcatenationIndentation:
Enabled: true
Lint/AmbiguousOperatorPrecedence:
Enabled: true
Lint/NonAtomicFileOperation:
Enabled: true
Style/EmptyHeredoc:
Enabled: true
Style/RedundantHeredocDelimiterQuotes:
Enabled: true
Style/RedundantStringEscape:
Enabled: true
Style/ReturnNilInPredicateMethodDefinition:
Enabled: true

# Enable our own pending cops.

Expand Down Expand Up @@ -167,6 +173,8 @@ RSpec/NoExpectationExample:
Enabled: true
RSpec/PendingWithoutReason:
Enabled: true
RSpec/ReceiveMessages:
Enabled: true
RSpec/RedundantAround:
Enabled: true
RSpec/SkipBlockInsideExample:
Expand Down
6 changes: 3 additions & 3 deletions lib/rubocop/cop/rspec/described_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ def offensive?(node)
end

def offensive_described_class?(node)
return unless node.const_type?
return false unless node.const_type?

# E.g. `described_class::CONSTANT`
return if contains_described_class?(node)
return false if contains_described_class?(node)

nearest_described_class, = node.each_ancestor(:block)
.map { |ancestor| described_constant(ancestor) }.find(&:itself)

return if nearest_described_class.equal?(node)
return false if nearest_described_class.equal?(node)

full_const_name(nearest_described_class) == full_const_name(node)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec/empty_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ def offensive?(body)
end

def conditionals_with_examples?(body)
return unless body.begin_type? || body.case_type?
return false unless body.begin_type? || body.case_type?

body.each_descendant(:if, :case).any? do |condition_node|
examples_in_branches?(condition_node)
end
end

def examples_in_branches?(condition_node)
return if !condition_node.if_type? && !condition_node.case_type?
return false if !condition_node.if_type? && !condition_node.case_type?

condition_node.branches.any? { |branch| examples?(branch) }
end
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec/empty_line_after_example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def consecutive_one_liner?(node)

def next_one_line_example?(node)
next_sibling = node.right_sibling
return unless next_sibling
return unless example?(next_sibling)
return false unless next_sibling
return false unless example?(next_sibling)

next_sibling.single_line?
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/pending.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def on_send(node)
private

def skipped?(node)
skippable?(node) && skipped_in_metadata?(node) ||
(skippable?(node) && skipped_in_metadata?(node)) ||
skipped_regular_example_without_body?(node)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/predicate_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def predicate_matcher_name?(name)

return false if allowed_explicit_matchers.include?(name)

name.start_with?('be_', 'have_') && !name.end_with?('?') ||
(name.start_with?('be_', 'have_') && !name.end_with?('?')) ||
%w[include respond_to].include?(name)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/receive_messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def item_range_by_whole_lines(item)
end

def heredoc_or_splat?(node)
(node.str_type? || node.dstr_type?) && node.heredoc? ||
((node.str_type? || node.dstr_type?) && node.heredoc?) ||
node.splat_type?
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/unspecified_exception.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def empty_exception_matcher?(node)
end

def block_with_args?(node)
return unless node&.block_type?
return false unless node&.block_type?

node.arguments?
end
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec/variable_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def correct_variable(variable)
end

def style_offense?(variable)
style == :symbols && string?(variable) ||
style == :strings && symbol?(variable)
(style == :symbols && string?(variable)) ||
(style == :strings && symbol?(variable))
end

def string?(node)
Expand Down
2 changes: 1 addition & 1 deletion spec/support/file_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ def create_file(file_path, content)

def create_dir(file_path)
dir_path = File.dirname(file_path)
FileUtils.makedirs dir_path unless File.exist?(dir_path)
FileUtils.makedirs dir_path
end
end