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

[Fix #7396]: Display ABC components with the value #7399

Merged
merged 1 commit into from Oct 27, 2019

Conversation

avmnu-sng
Copy link
Contributor

@avmnu-sng avmnu-sng commented Oct 3, 2019

Providing component values gives more insights to fix the offense.

Metrics/AbcSize: Assignment Branch Condition size for choose_move is too high. [<8, 12, 6> 15.62/15]
definitetly provides more information than
Metrics/AbcSize: Assignment Branch Condition size for choose_move is too high. [15.62/15]


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@bbatsov
Copy link
Collaborator

bbatsov commented Oct 25, 2019

The suggestion is fine by me, but I wonder if the extra info won't be confusing to some users. @rubocop-hq/rubocop-core what do you think about this?

@avmnu-sng
Copy link
Contributor Author

The suggestion is fine by me, but I wonder if the extra info won't be confusing to some users. @rubocop-hq/rubocop-core what do you think about this?

@bbatsov Might be confusing for few, but ideally, without displaying each component the ABC Size value is nothing but just a decimal value IMHO. One would never be sure about what individual components' values are unless count these manually.

CHANGELOG.md Outdated
@@ -24,6 +24,7 @@
* [#7317](https://github.com/rubocop-hq/rubocop/pull/7317): Add new formatter `pacman`. ([@crojasaragonez][])
* [#6075](https://github.com/rubocop-hq/rubocop/issues/6075): Support `IgnoredPatterns` option for `Naming/MethodName` cop. ([@koic][])
* [#7335](https://github.com/rubocop-hq/rubocop/pull/7335): Add todo as an alias to disable. `--disable-uncorrectable` will now disable cops using `rubocop:todo` instead of `rubocop:disable`. ([@desheikh][])
* [#7396](https://github.com/rubocop-hq/rubocop/issues/7396): Display assignments, branches, and, conditions values with the offence. ([@avmnu-sng][])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Move this to the master branch. I'd put it under Changes there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@bbatsov
Copy link
Collaborator

bbatsov commented Oct 25, 2019

Yeah, that's a fair point. I wonder if we shouldn't put an (A), (B) and (C) after each number, but I guess we can move forward without them.

You'll also have to rebase on top of master.

Math.sqrt(@assignment**2 + @branch**2 + @condition**2).round(2)
[
Math.sqrt(@assignment**2 + @branch**2 + @condition**2).round(2),
"<#{@assignment},#{@branch},#{@condition}>"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might be a good idea to add a space after each ,.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, agreed. Updated.

@avmnu-sng avmnu-sng force-pushed the avmnusng-fix-7396 branch 2 times, most recently from 7bf1cdc to b14d52e Compare October 25, 2019 17:14
@avmnu-sng
Copy link
Contributor Author

Yeah, that's a fair point. I wonder if we shouldn't put an (A), (B) and (C) after each number, but I guess we can move forward without them.

You'll also have to rebase on top of master.

Usually, we write vectors like (a, b, c, d) or <a, b, c, d>, But here we already use [], so not sure which one is visually good, [<a, b, c> value/max] or [(a, b, c) value/max]

@avmnu-sng avmnu-sng force-pushed the avmnusng-fix-7396 branch 2 times, most recently from 18120d2 to b066dd0 Compare October 25, 2019 17:28
CHANGELOG.md Outdated
@@ -14,6 +14,7 @@

* [#7446](https://github.com/rubocop-hq/rubocop/issues/7446): Add `merge` to list of non-mutating methods. ([@cstyles][])
* [#7077](https://github.com/rubocop-hq/rubocop/issues/7077): Rename `Unneeded*` cops to `Redundant*` (e.g., `Style/UnneededPercentQ` becomes `Style/RedundantPercentQ`). ([@scottmatthewman][])
* [#7396](https://github.com/rubocop-hq/rubocop/issues/7396): Display assignments, branches, and, conditions values with the offence. ([@avmnu-sng][])
Copy link
Member

Choose a reason for hiding this comment

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

There is an unnecessary comma.

-Display assignments, branches, and, conditions
+Display assignments, branches, and conditions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

CHANGELOG.md Outdated
@@ -4242,3 +4243,4 @@
[@jfhinchcliffe]: https://github.com/jfhinchcliffe
[@jdkaplan]: https://github.com/jdkaplan
[@cstyles]: https://github.com/cstyles
[@avmnu-sng]: https://github.com/username
Copy link
Member

Choose a reason for hiding this comment

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

It should be replaced with your account name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How silly! Fixed

@koic
Copy link
Member

koic commented Oct 26, 2019

After understanding <A, B, C>, there is no problem, but I was a little confused when I first saw it.

Providing component values gives more insights to fix the offense.
@bbatsov bbatsov merged commit bb55659 into rubocop:master Oct 27, 2019
@bbatsov
Copy link
Collaborator

bbatsov commented Oct 27, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants