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

Increase rubocop version to 0.51.x & remove Ruby 2.0 testing #15

Merged
merged 6 commits into from
Jan 19, 2018

Conversation

thomasriley
Copy link
Contributor

@thomasriley thomasriley commented Nov 20, 2017

Pull Request Checklist

sensu-plugins/community#77

General

Purpose

Increase rubocop version for CVE.

Known Compatibility Issues

Now requires Ruby 2.1 and greater

@thomasriley
Copy link
Contributor Author

Tests failed due to lots of rubocop failures. Working through them now :)

Copy link
Member

@majormoses majormoses left a comment

Choose a reason for hiding this comment

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

Some minor tweaks as to where it would be disabled inline vs the whole file.

@@ -49,6 +49,8 @@ class ZookeeperMetrics < Sensu::Plugin::Metric::CLI::Graphite
default: 2181,
proc: proc(&:to_i)

# TODO: Remove below when Rubocop is updated (https://github.com/sensu-plugins/community/issues/77#issuecomment-345813238)
# rubocop:disable Style/CommentedKeyword
Copy link
Member

Choose a reason for hiding this comment

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

this should go on the same line as the offense to disable it inline.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oddly on this one, when disabling inline it raises another (possibly erroneous) warning:

bin/metrics-zookeeper-cluster.rb:53:159: W: Unnecessary disabling of Style/CommentedKeyword.
  def follow_url(uri_str, agent = "sensu-plugins-zookeeper/#{SensuPluginsZookeeper::Version::VER_STRING}", max_attempts = 10, timeout = 10) # rubocop:disable Style/CommentedKeyword, Metrics/LineLength

I have instead changed it to disable this cop on just the function in question. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

😢 sounds like we have to choose one bad or the other. Go for it disabling the whole file.

Copy link
Member

Choose a reason for hiding this comment

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

Actually the best solution would be to just break up the parameters on that line. That way nothing needs disabling and it actually reads better.

@@ -119,6 +121,8 @@ def run
timestamp = Time.now.to_i

json = exhibitor_status

# rubocop:disable Metrics/BlockLength
Copy link
Member

Choose a reason for hiding this comment

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

this should go on the same line as the offense to disable it inline.

@@ -4,14 +4,14 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'date'
require_relative 'lib/sensu-plugins-zookeeper'

Gem::Specification.new do |s|
Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength
Copy link
Member

Choose a reason for hiding this comment

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

👍

@majormoses majormoses changed the title Increase rubocop version to 0.51+ & remove Ruby 2.0 testing Increase rubocop version to 0.51.x & remove Ruby 2.0 testing Nov 20, 2017
@majormoses
Copy link
Member

also just a minor nitpick your commit message and PR title (fixed) says 0.51.0+ which would be equivalent to >= 0.51.0 what we have done is ~> 0.51.0 which is called Pessimistic Versioning constraint which in this case would be equivalent of ['>= 0.51.0', '< 0.52.0' ] which is very different. Normally people lock pessimistically on the minor rather than the patch which means any greater than the specified minor within the same major. The reason we don't do this with rubocop is that with each new minors they have new/changed rules and it would cause a lot of code thrash and unfinished PRs.

@majormoses
Copy link
Member

@thomasriley any chance you can come back and rebase? I'd prefer if we lock it more closely to avoid rubocop randomly deciding to change a rule and now suddenly unrelated code to the PR starts failing lint.

@majormoses
Copy link
Member

@thomasriley I rebased on your behalf and made a minor tweak.

@majormoses
Copy link
Member

Assuming the tests pass now (they should) I think this is good to go, Ideally if you could squash to a single commit that would be best. If not I can do it for you.

@@ -16,3 +16,4 @@ mkmf.log
.DS_Store
.idea/*
*.gem
/vendor/
Copy link
Member

Choose a reason for hiding this comment

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

probably better to use vendor/* as this will catch anything with vendor in its name (not that I can think of a great real use case that this blocks).

@majormoses majormoses merged commit a4ef8fe into sensu-plugins:master Jan 19, 2018
@majormoses
Copy link
Member

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.

2 participants