-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
Add RuboCop testing #112
Add RuboCop testing #112
Conversation
else | ||
break | ||
end | ||
break unless answer.empty? || answer == 'y' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually refrain from using unless
with multiple conditions as I think it's more difficult to read (I usually have to read an unless
statement with multiple conditions multiple times before actually understanding it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
multiple conditions
I would agree is this was an if/elsif block, but its an if/else block so there is only one condition to chef, not multiple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, there are multiple conditions in the unless
part answer.empty? OR answer == 'y'
, but for this one I'll actually consider the unless
variant as it's easy to grip, so ignore my comment :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah i gotcha
%(#{prefix}.#{camelcase(key)}=#{value.call}) | ||
else | ||
%(#{prefix}.#{camelcase(key)}=#{value}) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I think that the changed version is more difficult to read, and it hurts my eyes :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/ConditionalAssignment
can force the original with EnforcedStyle: assign_inside_condition
if you would like :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please.
Things I don't agree with:
I'd also prefer if each "rule" change had its own commit as it would make it easier to discard certain changes. |
This was inconsistent throughout so i picked one, will force a trailing comma
This will affect all
The 2 links you mentioned are on the shell side, not ruby side
forces consistency, i can force
Can you elaborate on this? not following what you are referring too
Thought about it, but sometimes a line is affected by several rules so its hard to revert a commit in the middle |
Ah :)
That's unfortunate :/.
I know, which is why I said it was weird :). I don't agree with the motivation for using
Not really sure what this means? Is there a rule for forcing spaces before block braces but not for hashes? If so that sounds fine.
Sure. What I was referring to was method calls as: opts[:env_path] = value_for_platform_family({
'debian' => '/etc/default/kafka',
'default' => '/etc/sysconfig/kafka',
}) Whereas the rubocop rules suggests that the |
scratch that... looks like
will look more at this
I can force a space or no space, (actually the cop is
Gotcha, this is |
Right now I'm leaning towards having anything that creates arrays/lists use
Yeah. On second thought I don't really have a strong preference for this, so it's okay to include that rule (i.e. remove the redundant braces). |
Cool, thanks for all the feedback! i will work on updates today |
1f8d259
to
d2a5b09
Compare
The the spaces after
The way the |
Besides the formatting in the last comment, i think i addressed the feedback |
@mthssdrbrg any further thoughts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in general, but there are some inconsistencies especially with trailing commas, that rubocop doesn't complain about when I run it locally (which is really weird...).
%(#{prefix}.#{camelcase(key)}=#{value.call}) | ||
else | ||
%(#{prefix}.#{camelcase(key)}=#{value}) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please.
daemon_name: 'kafka', | ||
port: node['kafka']['broker']['port'], | ||
user: node['kafka']['user'], | ||
env_path: kafka_init_opts[:env_path], | ||
ulimit: node['kafka']['ulimit_file'], | ||
kill_timeout: node['kafka']['kill_timeout'], | ||
}) | ||
kill_timeout: node['kafka']['kill_timeout'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happened to the trailing comma here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed per Style/TrailingCommaInArguments
owner: 'root', | ||
group: 'root', | ||
mode: script_permissions, | ||
source: source_template, | ||
}) | ||
source: source_template |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with trailing comma here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed per Style/TrailingCommaInArguments
}) | ||
expect(chef_run).to run_execute('extract-kafka').with( | ||
cwd: %(#{Dir.tmpdir}/kafka-build) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think this could be collapsed to a single line, i.e.
expect(chef_run).to run_execute('extract-kafka').with(cwd: %(#{Dir.tmpdir}/kafka-build))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently, this is consistent style
I can make it inconsistent if you prefer
cookbook = Stove::Cookbook.new(Dir.pwd) | ||
version = cookbook.tag_version | ||
release_name = %(kafka-cookbook-#{version}) | ||
archive_path = ::File.join('pkg', sprintf('kafka-cookbook-%s.tar.gz', version)) | ||
archive_path = ::File.join('pkg', "#{release_name}.tar.gz") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would prefer if this was switched out to a format(...)
.
'default' => 'systemd/default.erb' | ||
}) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are quite some inconsistencies in this method with regards to trailing commas, though rubocop
doesn't complain when I check this file locally which I think is quite weird?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing comma only applies to multiline hashes, not method calls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me know if you want Style/TrailingCommaInArguments
disabled anyway
addressed all feedback |
You want me to squash the commits or are you good with the history? |
I'm good with the history, and I was hoping to merge this yesterday but I wanted to go through the changes one more time but ran out of time, will get to it tonight. Thanks a lot for the contribution (and your patience!) @shortdudey123. |
Cool and no problem! :) |
Merged in 584b40e. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Adds rubocop to standardize syntax
Let me know if there is anything you don't agree with