diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-01-09 18:09:01 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-09 18:09:01 +0900 |
commit | ea65d92f1924648e72f93bb0e8e5fc62a56d0bac (patch) | |
tree | 9e8ebde83d6f1fd2c0eaff195ee54c3f42e3ae88 /railties | |
parent | 69ca787bd26c0306cdfde25de76036686fc39f4f (diff) | |
download | rails-ea65d92f1924648e72f93bb0e8e5fc62a56d0bac.tar.gz rails-ea65d92f1924648e72f93bb0e8e5fc62a56d0bac.tar.bz2 rails-ea65d92f1924648e72f93bb0e8e5fc62a56d0bac.zip |
Enable `Lint/UselessAssignment` cop to avoid unused variable warnings (#34904)
* Enable `Lint/UselessAssignment` cop to avoid unused variable warnings
Since we've addressed the warning "assigned but unused variable"
frequently.
370537de05092aeea552146b42042833212a1acc
3040446cece8e7a6d9e29219e636e13f180a1e03
5ed618e192e9788094bd92c51255dda1c4fd0eae
76ebafe594fc23abc3764acc7a3758ca473799e5
And also, I've found the unused args in c1b14ad which raises no warnings
by the cop, it shows the value of the cop.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/code_statistics.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/plugin/plugin_generator.rb | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/railties/lib/rails/code_statistics.rb b/railties/lib/rails/code_statistics.rb index 19d331ff30..09082282f3 100644 --- a/railties/lib/rails/code_statistics.rb +++ b/railties/lib/rails/code_statistics.rb @@ -95,8 +95,8 @@ class CodeStatistics #:nodoc: end def print_line(name, statistics) - m_over_c = (statistics.methods / statistics.classes) rescue m_over_c = 0 - loc_over_m = (statistics.code_lines / statistics.methods) - 2 rescue loc_over_m = 0 + m_over_c = (statistics.methods / statistics.classes) rescue 0 + loc_over_m = (statistics.code_lines / statistics.methods) - 2 rescue 0 print "| #{name.ljust(20)} " HEADERS.each_key do |k| diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb index 239b3a5739..294c8a2609 100644 --- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb +++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb @@ -349,9 +349,9 @@ task default: :test def wrap_in_modules(unwrapped_code) unwrapped_code = "#{unwrapped_code}".strip.gsub(/\s$\n/, "") modules.reverse.inject(unwrapped_code) do |content, mod| - str = "module #{mod}\n" - str += content.lines.map { |line| " #{line}" }.join - str += content.present? ? "\nend" : "end" + str = +"module #{mod}\n" + str << content.lines.map { |line| " #{line}" }.join + str << (content.present? ? "\nend" : "end") end end |