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

Un Seattle #15561

Merged
merged 2 commits into from
Sep 6, 2017
Merged

Un Seattle #15561

merged 2 commits into from
Sep 6, 2017

Conversation

bdunne
Copy link
Member

@bdunne bdunne commented Jul 12, 2017

While building ManageIQ/guides#228 I tested against this repo and here are the changes. rubocop -a did almost everything here. There were only a few that I had to manually fix because autocorrect would blow up on them.

I also ignored the following in this PR, but didn't add exceptions for them since I believe they are deprecated, but didn't want to introduce a lot of code change here.

  • validates_format_of
  • validates_inclusion_of
  • validates_presence_of
  • validates_uniqueness_of

Thanks @NickLaMuro for inspiring me to search for this cop again 😄

@NickLaMuro
Copy link
Member

I have created a monster... 😲

@bdunne bdunne changed the title Un seattle Un Seattle Jul 12, 2017
Copy link
Member

@NickLaMuro NickLaMuro left a comment

Choose a reason for hiding this comment

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

From a technical standpoint, I think 99% of this is fine, and I only disagree with a few of these changes syntactically speaking (most are probably subjective).

But I am only going to "Comment" on this PR for a review, because objectively speaking I disagree with this PR and it's sister PR ManageIQ/guides#228, but that is from a personal standpoint. I get "why" you are pushing for this from a project maintenance standpoint, but that doesn't mean I have to like it... (honestly... makes me feel like I am writing Javascript or Go...)

That said, I would say that half of these are log.X statements, with some throw, yield and others tossed in there as well, and those updates probably are overkill for what you are trying to accomplish. But that is probably up to the opinions of those reviewing ManageIQ/guides#228, so I will leave the decisions regarding those bits to the reviewers of 228. Brought up what I thought was relevant to that PR in this review, but will leave it up to you and the others to determine what you chose to act on from that.

version "#{API_CMD} #{VERSION} - ManageIQ REST API Access Script"
banner <<-EOS
version("#{API_CMD} #{VERSION} - ManageIQ REST API Access Script")
banner(<<-EOS)
Copy link
Member

Choose a reason for hiding this comment

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

I think putting HEREDOC statements in parens looks awful and is quiet confusing. It also doesn't conform from what I assumes one of it's roots is, bash/shell programming: http://tldp.org/LDP/abs/html/here-docs.html

@@ -98,7 +98,7 @@ def table_dump

pg_dump_result = AwesomeSpawn.run("pg_dump", :params => params)

raise ColumnOrderingError <<-ERROR.gsub!(/^ +/, "") if pg_dump_result.failure?
raise ColumnOrderingError(<<-ERROR.gsub!(/^ +/, "")) if pg_dump_result.failure?
Copy link
Member

Choose a reason for hiding this comment

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

In the case of these, I would say these errors should be made into local variables, and loaded into this method, instead of being defined inside of the raise call:

if pg_dump_result.failure?
  err_message = <<-ERROR.gsub!(/^ +/, "")
    '#{pg_dump_result.command_line}' failed with #{pg_dump_result.exit_status}:
    
    stdout: #{pg_dump_result.output}
    stderr: #{pg_dump_result.error}
  ERROR
  raise ColumnOrderingError(err_message)
end

Copy link
Member Author

Choose a reason for hiding this comment

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

completely agree, but I think it's out of scope for this PR

@@ -33,10 +33,10 @@ def image_path(path, options = {})
Dir[ManageIQ::Gems::Pending.root.join("spec/support/custom_matchers/*.rb")].each { |f| require f }

RSpec.configure do |config|
config.expect_with :rspec do |c|
config.expect_with(:rspec) do |c|
Copy link
Member

Choose a reason for hiding this comment

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

Confused at why we have changes to the spec/ dir, when you ignore it in ManageIQ/guides#228.

Copy link
Member Author

Choose a reason for hiding this comment

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

At first, I tried to include everything except for *_spec.rb, but that was too optimistic, so I changed the config to exclude spec/*, but didn't remove the changes from this PR yet.

@@ -8,7 +8,7 @@ class ResourceSharer

attr_accessor :user, :resource, :tenants, :features, :allow_tenant_inheritance

with_options :presence => true do
with_options(:presence => true) do
Copy link
Member

Choose a reason for hiding this comment

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

I would argue that this is a DSL type syntax, and should be left as is.

opt :serverid, "Server Id", :short => "s", :default => 0
opt :path, "Path within advanced settings hash", :short => "p", :default => ""
opt :value, "New value for setting", :short => "v", :default => ""
opt(:dry_run, "Dry Run", :short => "d")
Copy link
Member

Choose a reason for hiding this comment

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

I also think that these opt fall under the umbrella of "DSL"

Copy link
Member

Choose a reason for hiding this comment

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

Yes these are DSL, IMO

@@ -18,8 +18,8 @@ module ActsAsMiqSetMember
include RelationshipMixin
self.default_relationship_type = "membership"

alias_with_relationship_type :memberof, :parents
alias_with_relationship_type :make_not_memberof, :remove_parent
alias_with_relationship_type(:memberof, :parents)
Copy link
Member

Choose a reason for hiding this comment

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

I see all of these calls to alias_with_relationship_type as a DSL as well. Arguably this is one that we own (I think), and that would be a slippery slop of how much of our own DSLs we include in the blacklist in ManageIQ/guides#228 .

Copy link
Member

Choose a reason for hiding this comment

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

I agree, the intention here was for it to be a DSL.

config/routes.rb Outdated

# Let's serve pictures directly from the DB
get '/pictures/:basename' => 'picture#show', :basename => /[\da-zA-Z]+\.[\da-zA-Z]+/
get('/pictures/:basename' => 'picture#show', :basename => /[\da-zA-Z]+\.[\da-zA-Z]+/)
Copy link
Member

Choose a reason for hiding this comment

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

DSL?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, the routes file is all DSL

@@ -22,7 +22,7 @@ def cockpit_url
end

def ipv4_address
ipaddresses.find { |ip| (IPAddr.new ip).ipv4? }
ipaddresses.find { |ip| IPAddr.new(ip).ipv4? }
Copy link
Member

Choose a reason for hiding this comment

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

Just wanted to say that this is probably how this one should have been written in the first place.

@@ -6,7 +6,7 @@ class MiqReportResult < ApplicationRecord
belongs_to :miq_task
has_one :binary_blob, :as => :resource, :dependent => :destroy
has_many :miq_report_result_details, :dependent => :delete_all
has_many :html_details, -> { where "data_type = 'html'" }, :class_name => "MiqReportResultDetail", :foreign_key => "miq_report_result_id"
has_many :html_details, -> { where("data_type = 'html'") }, :class_name => "MiqReportResultDetail", :foreign_key => "miq_report_result_id"
Copy link
Member

Choose a reason for hiding this comment

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

Why isn't this just using the hash syntax? This is already a problem, just don't get the reason for the string based .where here.

Copy link
Member Author

Choose a reason for hiding this comment

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

¯\_(ツ)_/¯

@NickLaMuro
Copy link
Member

@bdunne Consider rebasing the last two commits you added prior to merging with the large one as they are just fixing up flubs from the auto-correct, and the correction commits just add noise when blaming in the future.

@jrafanie
Copy link
Member

but didn't want to introduce a lot of code change here.

+1,118 −1,123

Too late!

😆

@jrafanie
Copy link
Member

Wow. This was a lot of work. I don't know how to review it though.

@NickLaMuro
Copy link
Member

Wow. This was a lot of work. I don't know how to review it though.

@jrafanie While it doesn't help with the "volume" of changes, the following is a way to at least view the diff as a whole without needing to press "Load Diff" for half of the files.

$ vim -n <(curl -Ls https://github.com/ManageIQ/manageiq/pull/15561.diff)

@carbonin
Copy link
Member

I found a few others that seem DSL-ish to me and probably should be excluded.

  • throw
  • yield
  • module_function
  • define_callbacks
  • set_callback

@miq-bot
Copy link
Member

miq-bot commented Jul 14, 2017

This pull request is not mergeable. Please rebase and repush.

@miq-bot
Copy link
Member

miq-bot commented Jul 17, 2017

This pull request is not mergeable. Please rebase and repush.

@miq-bot
Copy link
Member

miq-bot commented Jul 26, 2017

This pull request is not mergeable. Please rebase and repush.

@miq-bot
Copy link
Member

miq-bot commented Aug 18, 2017

This pull request is not mergeable. Please rebase and repush.

@bdunne
Copy link
Member Author

bdunne commented Aug 28, 2017

🐢

@miq-bot
Copy link
Member

miq-bot commented Aug 29, 2017

This pull request is not mergeable. Please rebase and repush.

@miq-bot
Copy link
Member

miq-bot commented Aug 30, 2017

This pull request is not mergeable. Please rebase and repush.

@miq-bot
Copy link
Member

miq-bot commented Sep 4, 2017

This pull request is not mergeable. Please rebase and repush.

@miq-bot
Copy link
Member

miq-bot commented Sep 6, 2017

Checked commits bdunne/manageiq@83d2dd7~...266cde6 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
210 files checked, 21 offenses detected

app/models/bottleneck_event.rb

app/models/ext_management_system.rb

app/models/miq_alert.rb

app/models/miq_provision_virt_workflow.rb

  • ❗ - Line 873, Col 70 - Style/ExtraSpacing - Unnecessary spacing detected.
  • ❗ - Line 92, Col 55 - Rails/TimeZone - Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.to_i, Time.now.to_f instead.

app/models/miq_request_workflow.rb

  • ❗ - Line 1036, Col 98 - Rails/TimeZone - Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.to_i, Time.now.to_f instead.
  • ❗ - Line 1061, Col 96 - Rails/TimeZone - Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.to_i, Time.now.to_f instead.
  • ❗ - Line 452, Col 100 - Style/IfInsideElse - Convert if nested inside else to elsif.
  • ❗ - Line 609, Col 75 - Rails/TimeZone - Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.to_i, Time.now.to_f instead.
  • ❗ - Line 782, Col 45 - Rails/TimeZone - Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.to_i, Time.now.to_f instead.

app/models/mixins/retirement_mixin.rb

app/models/mixins/scanning_mixin.rb

  • ❗ - Line 254, Col 64 - Rails/TimeZone - Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.to_i, Time.now.to_f instead.

app/models/storage.rb

  • ❗ - Line 562, Col 50 - Rails/TimeZone - Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.to_i, Time.now.to_f instead.

app/models/vm_or_template.rb

app/models/vmdb_database_connection.rb

lib/extensions/ar_taggable.rb

tools/env_probe_event_catcher.rb

@jrafanie
Copy link
Member

jrafanie commented Sep 6, 2017

@NickLaMuro @Fryguy @chrisarcand what do you think? I don't seattle much but don't feel strongly either way about it's usage. It's very situational when it's ok in my eyes. I'm 'fine' with merging this but if we're going to do it, we should do it before we branch off of master.

@chrisarcand
Copy link
Member

Don't care either way, either :)

:shipit:

@Fryguy Fryguy merged commit 9291810 into ManageIQ:master Sep 6, 2017
@Fryguy
Copy link
Member

Fryguy commented Sep 6, 2017

YOLO merge.

@Fryguy Fryguy added this to the Sprint 69 Ending Sep 18, 2017 milestone Sep 6, 2017
@bdunne bdunne deleted the un_seattle branch September 6, 2017 18:59
cben added a commit to cben/manageiq that referenced this pull request Apr 14, 2018
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.

8 participants