From bb1ecdcc677bf6e68e0252505509c089619b5b90 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Thu, 1 Sep 2016 23:41:49 +0200 Subject: fixes remaining RuboCop issues [Vipul A M, Xavier Noria] --- activesupport/Rakefile | 2 +- activesupport/bin/generate_tables | 2 +- activesupport/lib/active_support/dependencies.rb | 2 +- .../lib/active_support/multibyte/unicode.rb | 24 +++++++++++----------- .../lib/active_support/notifications/fanout.rb | 2 +- .../multibyte_grapheme_break_conformance_test.rb | 2 +- .../multibyte_normalization_conformance_test.rb | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) (limited to 'activesupport') diff --git a/activesupport/Rakefile b/activesupport/Rakefile index 54d7a5c6f3..2e1c50cc3d 100644 --- a/activesupport/Rakefile +++ b/activesupport/Rakefile @@ -16,6 +16,6 @@ namespace :test do task :isolated do Dir.glob("test/**/*_test.rb").all? do |file| sh(Gem.ruby, "-w", "-Ilib:test", file) - end or raise "Failures" + end || raise("Failures") end end diff --git a/activesupport/bin/generate_tables b/activesupport/bin/generate_tables index 06dcff4e87..ef220e0329 100755 --- a/activesupport/bin/generate_tables +++ b/activesupport/bin/generate_tables @@ -84,7 +84,7 @@ module ActiveSupport def create_composition_map @ucd.codepoints.each do |_, cp| - if !cp.nil? and cp.combining_class == 0 and cp.decomp_type.nil? and !cp.decomp_mapping.nil? and cp.decomp_mapping.length == 2 and @ucd.codepoints[cp.decomp_mapping[0]].combining_class == 0 and !@ucd.composition_exclusion.include?(cp.code) + if !cp.nil? && cp.combining_class == 0 && cp.decomp_type.nil? && !cp.decomp_mapping.nil? && cp.decomp_mapping.length == 2 && @ucd.codepoints[cp.decomp_mapping[0]].combining_class == 0 && !@ucd.composition_exclusion.include?(cp.code) @ucd.composition_map[cp.decomp_mapping[0]] ||= {} @ucd.composition_map[cp.decomp_mapping[0]][cp.decomp_mapping[1]] = cp.code end diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 158bb402bd..216d52164e 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -371,7 +371,7 @@ module ActiveSupport #:nodoc: load_args = ["#{file_name}.rb"] load_args << const_path unless const_path.nil? - if !warnings_on_first_load or history.include?(expanded) + if !warnings_on_first_load || history.include?(expanded) result = load_file(*load_args) else enable_warnings { result = load_file(*load_args) } diff --git a/activesupport/lib/active_support/multibyte/unicode.rb b/activesupport/lib/active_support/multibyte/unicode.rb index ee657080b2..2159abef14 100644 --- a/activesupport/lib/active_support/multibyte/unicode.rb +++ b/activesupport/lib/active_support/multibyte/unicode.rb @@ -89,25 +89,25 @@ module ActiveSupport should_break = # GB3. CR X LF - if previous == database.boundary[:cr] and current == database.boundary[:lf] + if previous == database.boundary[:cr] && current == database.boundary[:lf] false # GB4. (Control|CR|LF) ÷ - elsif previous and in_char_class?(previous, [:control,:cr,:lf]) + elsif previous && in_char_class?(previous, [:control,:cr,:lf]) true # GB5. ÷ (Control|CR|LF) elsif in_char_class?(current, [:control,:cr,:lf]) true # GB6. L X (L|V|LV|LVT) - elsif database.boundary[:l] === previous and in_char_class?(current, [:l,:v,:lv,:lvt]) + elsif database.boundary[:l] === previous && in_char_class?(current, [:l,:v,:lv,:lvt]) false # GB7. (LV|V) X (V|T) - elsif in_char_class?(previous, [:lv,:v]) and in_char_class?(current, [:v,:t]) + elsif in_char_class?(previous, [:lv,:v]) && in_char_class?(current, [:v,:t]) false # GB8. (LVT|T) X (T) - elsif in_char_class?(previous, [:lvt,:t]) and database.boundary[:t] === current + elsif in_char_class?(previous, [:lvt,:t]) && database.boundary[:t] === current false # GB8a. Regional_Indicator X Regional_Indicator - elsif database.boundary[:regional_indicator] === previous and database.boundary[:regional_indicator] === current + elsif database.boundary[:regional_indicator] === previous && database.boundary[:regional_indicator] === current false # GB9. X Extend elsif database.boundary[:extend] === current @@ -158,7 +158,7 @@ module ActiveSupport def decompose(type, codepoints) codepoints.inject([]) do |decomposed, cp| # if it's a hangul syllable starter character - if HANGUL_SBASE <= cp and cp < HANGUL_SLAST + if HANGUL_SBASE <= cp && cp < HANGUL_SLAST sindex = cp - HANGUL_SBASE ncp = [] # new codepoints ncp << HANGUL_LBASE + sindex / HANGUL_NCOUNT @@ -167,7 +167,7 @@ module ActiveSupport ncp << (HANGUL_TBASE + tindex) unless tindex == 0 decomposed.concat ncp # if the codepoint is decomposable in with the current decomposition type - elsif (ncp = database.codepoints[cp].decomp_mapping) and (!database.codepoints[cp].decomp_type || type == :compatibility) + elsif (ncp = database.codepoints[cp].decomp_mapping) && (!database.codepoints[cp].decomp_type || type == :compatibility) decomposed.concat decompose(type, ncp.dup) else decomposed << cp @@ -186,11 +186,11 @@ module ActiveSupport pos += 1 lindex = starter_char - HANGUL_LBASE # -- Hangul - if 0 <= lindex and lindex < HANGUL_LCOUNT + if 0 <= lindex && lindex < HANGUL_LCOUNT vindex = codepoints[starter_pos+1] - HANGUL_VBASE rescue vindex = -1 - if 0 <= vindex and vindex < HANGUL_VCOUNT + if 0 <= vindex && vindex < HANGUL_VCOUNT tindex = codepoints[starter_pos+2] - HANGUL_TBASE rescue tindex = -1 - if 0 <= tindex and tindex < HANGUL_TCOUNT + if 0 <= tindex && tindex < HANGUL_TCOUNT j = starter_pos + 2 eoa -= 2 else @@ -392,7 +392,7 @@ module ActiveSupport database.codepoints string.each_codepoint.map do |codepoint| cp = database.codepoints[codepoint] - if cp and (ncp = cp.send(mapping)) and ncp > 0 + if cp && (ncp = cp.send(mapping)) && ncp > 0 ncp else codepoint diff --git a/activesupport/lib/active_support/notifications/fanout.rb b/activesupport/lib/active_support/notifications/fanout.rb index 055ff6e211..9da115f552 100644 --- a/activesupport/lib/active_support/notifications/fanout.rb +++ b/activesupport/lib/active_support/notifications/fanout.rb @@ -68,7 +68,7 @@ module ActiveSupport module Subscribers # :nodoc: def self.new(pattern, listener) - if listener.respond_to?(:start) and listener.respond_to?(:finish) + if listener.respond_to?(:start) && listener.respond_to?(:finish) subscriber = Evented.new pattern, listener else subscriber = Timed.new pattern, listener diff --git a/activesupport/test/multibyte_grapheme_break_conformance_test.rb b/activesupport/test/multibyte_grapheme_break_conformance_test.rb index 5dc42df08d..04a7d290d9 100644 --- a/activesupport/test/multibyte_grapheme_break_conformance_test.rb +++ b/activesupport/test/multibyte_grapheme_break_conformance_test.rb @@ -33,7 +33,7 @@ class MultibyteGraphemeBreakConformanceTest < ActiveSupport::TestCase lines = 0 max_test_lines = 0 # Don't limit below 21, because that's the header of the testfile File.open(File.join(CACHE_DIR, UNIDATA_FILE), "r") do | f | - until f.eof? || (max_test_lines > 21 and lines > max_test_lines) + until f.eof? || (max_test_lines > 21 && lines > max_test_lines) lines += 1 line = f.gets.chomp! next if line.empty? || line.start_with?("#") diff --git a/activesupport/test/multibyte_normalization_conformance_test.rb b/activesupport/test/multibyte_normalization_conformance_test.rb index 716e6487aa..e013bd578f 100644 --- a/activesupport/test/multibyte_normalization_conformance_test.rb +++ b/activesupport/test/multibyte_normalization_conformance_test.rb @@ -88,7 +88,7 @@ class MultibyteNormalizationConformanceTest < ActiveSupport::TestCase lines = 0 max_test_lines = 0 # Don't limit below 38, because that's the header of the testfile File.open(File.join(CACHE_DIR, UNIDATA_FILE), "r") do | f | - until f.eof? || (max_test_lines > 38 and lines > max_test_lines) + until f.eof? || (max_test_lines > 38 && lines > max_test_lines) lines += 1 line = f.gets.chomp! next if line.empty? || line.start_with?("#") -- cgit v1.2.3