This is an automated email from the ASF dual-hosted git repository. tjwp pushed a commit to branch tjwp-rubocop-1.14 in repository https://gitbox.apache.org/repos/asf/avro.git
commit 6e23fecc0ed01466dc9bf403614f1206c7e46489 Author: Tim Perkins <[email protected]> AuthorDate: Sun May 9 08:23:42 2021 -0400 Enable new Lint cops --- lang/ruby/.rubocop.yml | 37 ++++++++++++++++++++++++++++++ lang/ruby/lib/avro/io.rb | 4 +--- lang/ruby/lib/avro/schema_compatibility.rb | 2 ++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/lang/ruby/.rubocop.yml b/lang/ruby/.rubocop.yml index 03d389f..055f94d 100644 --- a/lang/ruby/.rubocop.yml +++ b/lang/ruby/.rubocop.yml @@ -48,3 +48,40 @@ Style/MutableConstant: Style/RedundantFreeze: Enabled: true + +# New cops from 1.x. Lines below can be removed after upgrading to rubocop > 2.0. + +Gemspec/DateAssignment: # (new in 1.10) + Enabled: true +Lint/AmbiguousAssignment: # (new in 1.7) + Enabled: true +Lint/DeprecatedConstants: # (new in 1.8) + Enabled: true +Lint/DuplicateBranch: # (new in 1.3) + Enabled: true +Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1) + Enabled: true +Lint/EmptyBlock: # (new in 1.1) + Enabled: true +Lint/EmptyClass: # (new in 1.3) + Enabled: true +Lint/LambdaWithoutLiteralBlock: # (new in 1.8) + Enabled: true +Lint/NoReturnInBeginEndBlocks: # (new in 1.2) + Enabled: true +Lint/NumberedParameterAssignment: # (new in 1.9) + Enabled: true +Lint/OrAssignmentToConstant: # (new in 1.9) + Enabled: true +Lint/RedundantDirGlobSort: # (new in 1.8) + Enabled: true +Lint/SymbolConversion: # (new in 1.9) + Enabled: true +Lint/ToEnumArguments: # (new in 1.1) + Enabled: true +Lint/TripleQuotes: # (new in 1.9) + Enabled: true +Lint/UnexpectedBlockArity: # (new in 1.5) + Enabled: true +Lint/UnmodifiedReduceAccumulator: # (new in 1.1) + Enabled: true diff --git a/lang/ruby/lib/avro/io.rb b/lang/ruby/lib/avro/io.rb index 5a045cf..e6e3b32 100644 --- a/lang/ruby/lib/avro/io.rb +++ b/lang/ruby/lib/avro/io.rb @@ -393,13 +393,11 @@ module Avro case field_schema.type_sym when :null return nil - when :boolean - return default_value when :int, :long return Integer(default_value) when :float, :double return Float(default_value) - when :enum, :fixed, :string, :bytes + when :boolean, :enum, :fixed, :string, :bytes return default_value when :array read_array = [] diff --git a/lang/ruby/lib/avro/schema_compatibility.rb b/lang/ruby/lib/avro/schema_compatibility.rb index 910e1a5..93516be 100644 --- a/lang/ruby/lib/avro/schema_compatibility.rb +++ b/lang/ruby/lib/avro/schema_compatibility.rb @@ -62,6 +62,7 @@ module Avro end # Handle schema promotion + # rubocop:disable Lint/DuplicateBranch if w_type == :int && INT_COERCIBLE_TYPES_SYM.include?(r_type) return true elsif w_type == :long && LONG_COERCIBLE_TYPES_SYM.include?(r_type) @@ -73,6 +74,7 @@ module Avro elsif w_type == :bytes && r_type == :string return true end + # rubocop:enable Lint/DuplicateBranch if readers_schema.respond_to?(:match_schema?) readers_schema.match_schema?(writers_schema)
