Skip to content

Commit 541da7c

Browse files
authored
Merge pull request #1061 from koic/fix_a_false_positive_for_rails_http_status
[Fix #1060] Fix a false positive for `Rails/HttpStatus`
2 parents 9bb121a + ddd4a80 commit 541da7c

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#1060](https://github.com/rubocop/rubocop-rails/issues/1060): Fix a false positive for `Rails/HttpStatus` when using symbolic value that have no numeric value mapping. ([@koic][])

lib/rubocop/cop/rails/http_status.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def initialize(node)
133133
end
134134

135135
def offensive?
136-
!node.int_type? && !permitted_symbol?
136+
!node.int_type? && !permitted_symbol? && number
137137
end
138138

139139
def message

spec/rubocop/cop/rails/http_status_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,11 @@
125125
render :foo, status: :redirect
126126
RUBY
127127
end
128+
129+
it 'does not register an offense when using symbolic value that have no numeric value mapping' do
130+
expect_no_offenses(<<~RUBY)
131+
render json: { foo: 'bar' }, status: :ng
132+
RUBY
133+
end
128134
end
129135
end

0 commit comments

Comments
 (0)