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

Trying to appease Rubocop #4301

Merged
merged 37 commits into from Jan 4, 2016
Merged

Trying to appease Rubocop #4301

merged 37 commits into from Jan 4, 2016

Conversation

pathawks
Copy link
Member

Am going through this list of style issues and tackling the low hanging fruit. If this is productive, I may continue.

This is mostly for my own learning.

@envygeeks
Copy link
Contributor

Do you plan on doing more @pathawks because as far as I'm concerned as it stands right now this is ready to be merged and perfect!

@envygeeks
Copy link
Contributor

Well... asked too late since as I was asking you did more lol.

@pathawks
Copy link
Member Author

Well... asked too late since as I was asking you did more lol.

lol
Yes, I plan to work on this a bit more over the next couple of days. There are some failing tests that I need to investigate :rage4:

@pathawks
Copy link
Member Author

Failing tests seem unrelated. Drops have no method key?, which caused a wide variety of problems... :goberserk:

@pathawks
Copy link
Member Author

What is the best way to do a big PR like this? Should I just keep committing and then squash+merge when I finish / get bored?
Or you could merge this batch and I’ll just open another PR for the next batch?

@envygeeks
Copy link
Contributor

Squash likes but keep others as their own commits so there is a clear history. So for example you have two commits that have "key?" changes, those two should be squashed but everything else that isn't the same of another commit is easier to verify over multiple commits in this case.

@@ -130,7 +130,7 @@ def valid?(set)
# new_scope - the new scope hash
#
# Returns true if the new scope has precedence over the older
def has_precedence?(old_scope, new_scope)
def precedence?(old_scope, new_scope)
Copy link
Member Author

Choose a reason for hiding this comment

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

precedence? is private, so renaming is not a breaking change.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm gonna caution on the side of it not being entirely clear to the user, things like Rubocop tell you to only use private once but that's an ignorant approach considering I didn't even know it was private until I scrolled up quite a ways. They also tell you to indent on that private, which just muddies the code view.

I'm not against the change though, just saying it might not be clear to a user.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you have a suggestion for making it more clear?

Copy link
Contributor

Choose a reason for hiding this comment

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

For all my source, I disable Rubocops "worthless private" warning and add private above every private def no matter how many there are, so it's clear that method is private, the same way other languages enforce that kind of explicitness.

private
def method1
  #
end

private
def method2
  #
end

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I think I already disabled that in Jekyll too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I see that this convention is already implemented in most other parts of Jekyll.

@pathawks
Copy link
Member Author

pathawks commented Jan 1, 2016

Before:

119 files inspected, 1853 offenses detected

After:

119 files inspected, 1066 offenses detected

@pathawks
Copy link
Member Author

pathawks commented Jan 3, 2016

master after b7d5a26:

69 files inspected, 606 offenses detected

I will weed some of these commits out when I get the chance.

@envygeeks
Copy link
Contributor

It's gone down slightly more after further refinement, now it sits at 533 offenses as it stands.

 - Use array literal [] instead of Array.new
 - Use hash literal {} instead of Hash.new
 - Do not use semicolons to terminate expressions
 - Use \ instead of + or << to concatenate those strings
 - Prefer $LOAD_PATH over $:
 - Use && instead of and
 - Use || instead of or
 - %w-literals should be delimited by ( and )
Rubocop: Style/WordArray
 - Use %w or %W for array of words
 - Hash#has_key? is deprecated in favor of Hash#key?
Add method `key?` to Drop
 - Use delete! instead of gsub!
 - Use tr instead of gsub
 - Use hash rockets syntax
 - Extra empty line detected at class body end
 - Space missing after comma
Rubocop: Style/SpaceInsideBlockBraces
 - Favor unless over if for negative conditions
 - Pass &:to_sym as an argument to map instead of a block
 - Pass &:capitalize as an argument to select instead of a block
 - Pass &:to_s as an argument to map instead of a block
@pathawks
Copy link
Member Author

pathawks commented Jan 4, 2016

Down to 321, and I'm not sure why the test failed (only on 2.2)

Failure:
TestKramdown#test_: kramdown should render fenced code blocks with syntax highlighting.  [/home/travis/build/jekyll/jekyll/test/test_kramdown.rb:59]
Minitest::Assertion: Failed refutation, no message given
553 tests, 926 assertions, 1 failures, 0 errors, 0 skips

@envygeeks
Copy link
Contributor

It randomly fails on 2.2 because of bugs in 2.2 that were addressed in the latest 2.2 but Travis+RVM is absolutely totally broken so 2.2 points to the first release of 2.2. To fix it we have to point it to the full version of 2.2.* which is annoying to maintain.

 - Use proc instead of Proc.new
...and use lambda instead of proc
 - Unused block argument
@parkr
Copy link
Member

parkr commented Jan 4, 2016

Keep everything as individual commits, I think. I have encountered too many general "fix the style" commits for my liking.

 - Use next to skip iteration
 - Indent when as deep as case
 - Align else with if
Rubocop: Lint/EndAlignment
 - Align end with if
 - Use `attr_writer` to define trivial writer methods
 - Ternary operators must not be nested. Prefer if/else constructs instead.
 - Rewrite these with the positive case first
 - Avoid the use of Perl-style backrefs
 - Avoid using {...} for multi-line blocks
 - Space inside range literal
 - Don't use parentheses around the condition of an if
 - Trailing whitespace detected
Rubocop: Style/EmptyLines
 - Extra blank line detected
Rubocop: Style/EmptyLinesAroundBlockBody
 - Extra empty line detected at block body beginning
@@ -67,13 +65,11 @@ def build(site, options)
# options - A Hash of options passed to the command
#
# Returns nothing.
def watch(site, options)
def watch(_site, options)
Copy link
Member

Choose a reason for hiding this comment

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

you can make this just _, I think?

Copy link
Contributor

Choose a reason for hiding this comment

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

You can if you wish but he probably left it _site so the API is clear.

Copy link
Member Author

Choose a reason for hiding this comment

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

he probably left it _site so the API is clear.

Yup

@parkr
Copy link
Member

parkr commented Jan 4, 2016

Thanks, @pathawks!

parkr added a commit that referenced this pull request Jan 4, 2016
@parkr parkr merged commit 5580972 into jekyll:master Jan 4, 2016
parkr added a commit that referenced this pull request Jan 4, 2016
@parkr
Copy link
Member

parkr commented Jan 4, 2016

Down to 204 offenses. Thanks so much, @pathawks!

@pathawks pathawks deleted the rubocop branch January 4, 2016 20:36
@pathawks
Copy link
Member Author

pathawks commented Jan 4, 2016

Thank you both for helping me through this. I learned a lot along the way 👍

@jekyll jekyll locked and limited conversation to collaborators Feb 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants