Conversation
| sub_delims = CharacterClasses::SUB_DELIMS | ||
| if !self.host.nil? && (self.host =~ /[<>{}\/\\\?\#\@"[[:space:]]]/ || | ||
| (self.host[/^\[(.*)\]$/, 1] != nil && self.host[/^\[(.*)\]$/, 1] !~ | ||
| (self.host[/^\[(.*)\]$/, 1] && self.host[/^\[(.*)\]$/, 1] !~ |
There was a problem hiding this comment.
Style/RedundantSelf: Redundant self detected.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| "Cannot have a relative path with an authority set: '#{self.to_s}'" | ||
| end | ||
| if self.path != nil && !self.path.empty? && | ||
| if self.path && !self.path.empty? && |
There was a problem hiding this comment.
Style/RedundantSelf: Redundant self detected.
| if self.path != nil && !self.path.empty? && self.path[0..0] != SLASH && | ||
| self.authority != nil | ||
| if self.path && !self.path.empty? && self.path[0..0] != SLASH && | ||
| self.authority |
There was a problem hiding this comment.
Layout/MultilineOperationIndentation: Align the operands of a condition in an if statement spanning multiple lines.
Style/RedundantSelf: Redundant self detected.
| end | ||
| if self.path != nil && !self.path.empty? && self.path[0..0] != SLASH && | ||
| self.authority != nil | ||
| if self.path && !self.path.empty? && self.path[0..0] != SLASH && |
There was a problem hiding this comment.
Style/RedundantSelf: Redundant self detected.
| self.password != nil | ||
| if self.port || | ||
| self.user || | ||
| self.password |
There was a problem hiding this comment.
Layout/MultilineOperationIndentation: Align the operands of a condition in an if statement spanning multiple lines.
Style/RedundantSelf: Redundant self detected.
| uri_string = String.new | ||
| uri_string << "#{self.scheme}:" if self.scheme != nil | ||
| uri_string << "//#{self.authority}" if self.authority != nil | ||
| uri_string << "#{self.scheme}:" if self.scheme |
There was a problem hiding this comment.
Style/RedundantSelf: Redundant self detected.
| # @return [String] The URI's <code>String</code> representation. | ||
| def to_s | ||
| if self.scheme == nil && self.path != nil && !self.path.empty? && | ||
| if self.scheme == nil && self.path && !self.path.empty? && |
There was a problem hiding this comment.
Style/RedundantSelf: Redundant self detected.
Style/NilComparison: Prefer the use of the nil? predicate.
| # If the base path is empty and an authority segment has been | ||
| # defined, use a base path of SLASH | ||
| if base_path.empty? && self.authority != nil | ||
| if base_path.empty? && self.authority |
There was a problem hiding this comment.
Style/RedundantSelf: Redundant self detected.
| if uri.path == nil || uri.path.empty? | ||
| joined_path = self.path | ||
| if uri.query != nil | ||
| if uri.query |
There was a problem hiding this comment.
Metrics/BlockNesting: Avoid more than 3 levels of block nesting.
Style/ConditionalAssignment: Use the return of the conditional for variable assignment and comparison.
| site_string << "#{self.normalized_scheme}:" | ||
| end | ||
| if self.normalized_authority != nil | ||
| if self.normalized_authority |
There was a problem hiding this comment.
Style/RedundantSelf: Redundant self detected.
| @normalized_site ||= begin | ||
| site_string = "".dup | ||
| if self.normalized_scheme != nil | ||
| if self.normalized_scheme |
There was a problem hiding this comment.
Style/RedundantSelf: Redundant self detected.
| site_string << "#{self.scheme}:" if self.scheme != nil | ||
| site_string << "//#{self.authority}" if self.authority != nil | ||
| site_string << "#{self.scheme}:" if self.scheme | ||
| site_string << "//#{self.authority}" if self.authority |
There was a problem hiding this comment.
Style/RedundantSelf: Redundant self detected.
| site_string = "".dup | ||
| site_string << "#{self.scheme}:" if self.scheme != nil | ||
| site_string << "//#{self.authority}" if self.authority != nil | ||
| site_string << "#{self.scheme}:" if self.scheme |
There was a problem hiding this comment.
Style/RedundantSelf: Redundant self detected.
| if new_port != nil && !(new_port.to_s =~ /^\d+$/) | ||
| raise InvalidURIError, | ||
| "Invalid port number: #{new_port.inspect}" | ||
| if new_port && !(new_port.to_s =~ /^\d+$/) |
There was a problem hiding this comment.
Style/InverseMethods: Use !~ instead of inverting =~.
| # @param [String, Integer, #to_s] new_port The new port component. | ||
| def port=(new_port) | ||
| if new_port != nil && new_port.respond_to?(:to_str) | ||
| if new_port && new_port.respond_to?(:to_str) |
There was a problem hiding this comment.
Style/SafeNavigation: Use safe navigation (&.) instead of checking if an object exists before calling the method.
| end | ||
| authority << self.normalized_host | ||
| if self.normalized_port != nil | ||
| if self.normalized_port |
There was a problem hiding this comment.
Style/RedundantSelf: Redundant self detected.
| @normalized_authority ||= begin | ||
| authority = String.new | ||
| if self.normalized_userinfo != nil | ||
| if self.normalized_userinfo |
There was a problem hiding this comment.
Style/RedundantSelf: Redundant self detected.
| end | ||
| authority << self.host | ||
| if self.port != nil | ||
| if self.port |
There was a problem hiding this comment.
Style/RedundantSelf: Redundant self detected.
| self.host && @authority ||= begin | ||
| authority = String.new | ||
| if self.userinfo != nil | ||
| if self.userinfo |
There was a problem hiding this comment.
Style/RedundantSelf: Redundant self detected.
| } | ||
| components.each do |key, value| | ||
| if value != nil | ||
| if value |
There was a problem hiding this comment.
Style/Next: Use next to skip iteration.
| sub_delims = CharacterClasses::SUB_DELIMS | ||
| if !self.host.nil? && (self.host =~ /[<>{}\/\\\?\#\@"[[:space:]]]/ || | ||
| (self.host[/^\[(.*)\]$/, 1] != nil && self.host[/^\[(.*)\]$/, 1] !~ | ||
| (self.host[/^\[(.*)\]$/, 1] && self.host[/^\[(.*)\]$/, 1] !~ |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
nice simplifications! in a similar vein, what do you think of swapping |
Technically, if an object is not
nil, it is either a Booleanfalseor a truthy.I'm making an assumption here that
falsecan be ignored because this check is used against values set by:parsemethod.Therefore, the test for
!= nilis redundant.