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

More fixes #2515

Merged
merged 13 commits into from
Dec 20, 2015
Merged

More fixes #2515

merged 13 commits into from
Dec 20, 2015

Conversation

alexdowad
Copy link
Contributor

This is my next batched GH-issue-fixin' PR.

Regarding the new cop requested by @agrimm, which checks for paren-challenged method calls nested inside a paren-privileged method call, what do you think about this:

method_with_parens(block_taker { method_without_parens 1, 2 })

Is it good, or bad?

@bbatsov
Copy link
Collaborator

bbatsov commented Dec 19, 2015

Is it good, or bad?

This looks fine to me, as it's the nest method call is not something that would result in a method argument for the outer method.

@@ -662,6 +662,12 @@ Style/SingleLineBlockParams:
Style/SingleLineMethods:
AllowIfMethodIsEmpty: true

Style/SpecialGlobalVars:
EnforcedStyle: use_verbose_names
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd say those are "descriptive" and the others are "cryptic". :-)

Let's rename verbose to descriptive or english. I think verbose carries a different connotation.

@alexdowad
Copy link
Contributor Author

Thanks for all the helpful comments. PR updated.

I will probably push several more fixes to this branch over the coming days, but if and when you want to merge it, please go ahead; I can open another one.

@bbatsov
Copy link
Collaborator

bbatsov commented Dec 20, 2015

Apart from the failing build, all changes look good.

Your ConditionalAssignment changes are going to conflict with @rrosenblum's open PRs regarding it. Whoever is ready first for a merge won't have to deal with those. :-)

@alexdowad alexdowad force-pushed the more_fixes branch 2 times, most recently from f10c5dc to 209acf5 Compare December 20, 2015 20:09
…Vars

This is for people who like squinting at cryptic variable names and trying
to remember what they are for.
It checks for things like:

    foo(bar 1, 2)
The --stdin CLI option causes RuboCop to read source from stdin. Previously,
if this was combined with --autocorrect, an 'infinite loop' error would result.

Instead, autocorrect the code and print it to stdout (after an
easily-identifiable delimiter which separates it from other information
printed to stdout).
If 'attr_writer' appears after an access modifier, that means it's not useless.
…]= are the same

Previously, it would flag this:

    if something
      array << value
    else
      array[index] = value
    end
…to be 'namespace'

Like this:

    module Info
      VERSION = '1.2'
      AUTHOR  = 'No-one in particular'
    end

Such classes and modules won't be flagged even if they have no documentation
comment.
Do some major refactoring to ConditionalAssignment at the same time.
…fig from rubocop

This is not allowed:

    inherit_gem:
      rubocop: config/default.yml

...because it causes confusion. User configuration is ALREADY merged with the
default configuration, without explicitly inheriting it like this.

Thanks to Jonas Arvidsson for suggesting this.
…exits scope

So code like this:

    if condition
      raise 'exception'
    else
      ok
    end

...will be flagged. Instead, it should be:

    raise 'exception' if condition
    ok
@alexdowad
Copy link
Contributor Author

Updated PR. Fixed build. Also added one new cop... see the last commit.

This catches things like:

    if condition
      do_x
      do_z
    else
      do_y
      do_z
    end

...which should be:

    if condition
      do_x
    else
      do_y
    end
    do_z
bbatsov added a commit that referenced this pull request Dec 20, 2015
@bbatsov bbatsov merged commit d4aee5e into rubocop:master Dec 20, 2015
@bbatsov
Copy link
Collaborator

bbatsov commented Dec 20, 2015

I like the new cop - quite useful.

@alexdowad alexdowad deleted the more_fixes branch December 21, 2015 03:35
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.

2 participants