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

Re-enable Layout/SpaceAroundOperators cop #40436

Merged
merged 1 commit into from Oct 23, 2020

Conversation

kamipo
Copy link
Member

@kamipo kamipo commented Oct 23, 2020

We prefer space around operators, but Layout/SpaceAroundOperators cop
was temporarily disabled in #36943 since that cop changed to check
alignment strictly somehow.

In RuboCop 1.0.0, that is fixed by rubocop/rubocop#8906.

Related #38034 (comment), #39770 (comment).

We prefer space around operators, but `Layout/SpaceAroundOperators` cop
was temporarily disabled in rails#36943 since that cop changed to check
alignment strictly somehow.

In RuboCop 1.0.0, that is fixed by rubocop/rubocop#8906.

Related rails#38034 (comment),
rails#39770 (comment).
@@ -75,7 +75,7 @@ def fast_string_to_time(string)
usec = $7.to_i
usec_len = $7&.length
if usec_len&.< 6
usec *= 10 ** (6 - usec_len)
usec *= 10**(6 - usec_len)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is EnforcedStyleForExponentOperator configurable attributes, but here is only line that space around exponent operator, so I'll accept this change.

https://docs.rubocop.org/rubocop/1.0/cops_layout.html#configurable-attributes-41

% git grep -n ' \*\* '
activemodel/lib/active_model/type/helpers/time_value.rb:78:              usec *= 10 ** (6 - usec_len)
railties/lib/rails/commands/secrets/USAGE:1:=== ** DEPRECATED **

% git grep -n '[a-z0-9]\*\*[a-z0-9]'
actionpack/test/controller/parameters/parameters_permit_test.rb:62:    values += [0, 1.0, 2**128, BigDecimal(1)]
Binary file actiontext/test/fixtures/files/racecar.jpg matches
actionview/test/template/date_helper_test.rb:194:    assert_equal "about 3 years", distance_of_time_in_words(10**8)
actionview/test/template/date_helper_test.rb:195:    assert_equal "about 3 years", distance_of_time_in_words(0, 10**8)
actionview/test/template/number_helper_test.rb:117:    assert_equal "100&lt;script&gt;&lt;/script&gt;000 Quadrillion", number_to_human(10**20, delimiter: "<script></script>")
actionview/test/template/render_test.rb:157:    assert_equal "4", @view.render(inline: "(2**2).to_s", type: :ruby)
activejob/lib/active_job/exceptions.rb:26:      #   <tt>:exponentially_longer</tt>, which applies the wait algorithm of <tt>((executions**4) + (Kernel.rand * (executions**4) * jitter)) + 2</tt>
activejob/lib/active_job/exceptions.rb:137:          delay = executions**4
activemodel/lib/active_model/type/helpers/time_value.rb:28:          round_power = 10**number_of_insignificant_digits
activemodel/test/cases/validations/length_validation_test.rb:166:    bigmin = 2**30
activemodel/test/cases/validations/length_validation_test.rb:167:    bigmax = 2**32
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:588:          m.register_type %r(tinytext)i,   Type::Text.new(limit: 2**8 - 1)
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:589:          m.register_type %r(tinyblob)i,   Type::Binary.new(limit: 2**8 - 1)
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:590:          m.register_type %r(text)i,       Type::Text.new(limit: 2**16 - 1)
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:591:          m.register_type %r(blob)i,       Type::Binary.new(limit: 2**16 - 1)
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:592:          m.register_type %r(mediumtext)i, Type::Text.new(limit: 2**24 - 1)
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:593:          m.register_type %r(mediumblob)i, Type::Binary.new(limit: 2**24 - 1)
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:594:          m.register_type %r(longtext)i,   Type::Text.new(limit: 2**32 - 1)
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:595:          m.register_type %r(longblob)i,   Type::Binary.new(limit: 2**32 - 1)
activerecord/lib/active_record/fixtures.rb:464:    MAX_ID = 2**30 - 1
activerecord/test/cases/bind_parameter_test.rb:112:        topics = Topic.where(id: (1 .. bind_params_length).to_a << 2**63)
activerecord/test/cases/bind_parameter_test.rb:115:        topics = Topic.where.not(id: (1 .. bind_params_length).to_a << 2**63)
activerecord/test/cases/migration_test.rb:391:      world_population: 2**62,
activerecord/test/cases/migration_test.rb:406:    assert_equal 2**62, b.world_population
activerecord/test/cases/numeric_data_test.rb:22:      world_population: 2**62,
activerecord/test/cases/numeric_data_test.rb:33:    assert_equal 2**62, m1.world_population
activerecord/test/cases/numeric_data_test.rb:49:      world_population: 2**62,
activerecord/test/cases/numeric_data_test.rb:60:    assert_equal 2**62, m1.world_population
activerecord/test/cases/numeric_data_test.rb:77:        world_population: 2**62,
Binary file activestorage/test/fixtures/files/racecar.jpg matches
Binary file activestorage/test/fixtures/files/racecar.tif matches
Binary file activestorage/test/fixtures/files/racecar_rotated.jpg matches
Binary file activestorage/test/fixtures/files/video.webm matches
activesupport/lib/active_support/key_generator.rb:16:      @iterations = options[:iterations] || 2**16
activesupport/lib/active_support/number_helper/number_to_human_converter.rb:26:        @number = number / (10**exponent)
activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb:24:          human_size = number / (base**exponent)
activesupport/test/core_ext/numeric_ext_test.rb:107:    assert_equal 1.kilobyte**4, 1.terabyte
activesupport/test/core_ext/numeric_ext_test.rb:111:    assert_equal 1.kilobyte**5, 1.petabyte
activesupport/test/core_ext/numeric_ext_test.rb:112:    assert_equal 1.kilobyte**6, 1.exabyte
activesupport/test/core_ext/numeric_ext_test.rb:383:    assert_equal "100000 Quadrillion", (100**10).to_s(:human)
activesupport/test/core_ext/numeric_ext_test.rb:390:    assert_equal "100000000000000000000", (100**10).to_s(:invalid)
activesupport/test/core_ext/numeric_ext_test.rb:400:    assert_equal "100000000000000000000", (100**10).to_s
activesupport/test/core_ext/numeric_ext_test.rb:401:    assert_equal "1010110101111000111010111100010110101100011000100000000000000000000", (100**10).to_s(2)
Binary file guides/assets/images/association_basics/has_one_through.png matches
Binary file guides/assets/images/getting_started/rails_welcome.png matches
guides/source/active_support_core_extensions.md:2045:[].sum(1) {|n| n**3} # => 1

@kamipo kamipo merged commit 533c5c3 into rails:master Oct 23, 2020
@kamipo kamipo deleted the enable_space_around_operators branch October 23, 2020 11:40
koic added a commit to koic/oracle-enhanced that referenced this pull request Oct 23, 2020
Follow rails/rails#40436.

This PR enables `Layout/SpaceAroundOperators` cop.
koic added a commit to koic/oracle-enhanced that referenced this pull request Oct 23, 2020
Follow rails/rails#40436.

This PR enables `Layout/SpaceAroundOperators` cop.
koic added a commit to koic/rubocop-rails_config that referenced this pull request Oct 25, 2020
Follow rails/rails#40436.

This PR enables `Layout/SpaceAroundOperators` cop.
rails/rails#40436 setting requires
RuboCop 1.0 and RuboCop AST 1.0.1 or higher.
rubocop/rubocop#8919

Therefore this PR will be dropping versions that is lack for that requires.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants