Skip to content

Commit

Permalink
Merge pull request #70 from dblock/rubocop-0.60.0
Browse files Browse the repository at this point in the history
Upgraded RuboCop to 0.60.0.
  • Loading branch information
dblock committed Nov 9, 2018
2 parents aca182e + b57a2f5 commit de287d6
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 29 deletions.
54 changes: 43 additions & 11 deletions .rubocop_todo.yml
@@ -1,40 +1,65 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-09-25 10:29:59 -0400 using RuboCop version 0.45.0.
# on 2018-11-09 16:09:41 -0500 using RuboCop version 0.60.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 4
# Configuration parameters: Include.
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
Bundler/DuplicatedGem:
Exclude:
- 'Gemfile'

# Offense count: 2
Lint/DuplicateMethods:
Exclude:
- 'lib/mongoid/geospatial/fields/circle.rb'

# Offense count: 3
Metrics/AbcSize:
Max: 22

# Offense count: 21
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Max: 216

# Offense count: 1
Metrics/CyclomaticComplexity:
Max: 7

# Offense count: 15
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives.
# URISchemes: http, https
Metrics/LineLength:
Max: 113

# Offense count: 1
# Configuration parameters: CountComments.
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/MethodLength:
Max: 11

# Offense count: 1
Style/AccessorMethodName:
Naming/AccessorMethodName:
Exclude:
- 'spec/models/address.rb'

# Offense count: 9
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: io, id, to, by, on, in, at, ip, db
Naming/UncommunicativeMethodParamName:
Exclude:
- 'lib/mongoid/geospatial/fields/point.rb'
- 'lib/mongoid/geospatial/geometry_field.rb'

# Offense count: 3
Style/ClassVars:
Exclude:
- 'lib/mongoid/geospatial.rb'

# Offense count: 4
Style/CommentedKeyword:
Exclude:
- 'lib/mongoid/geospatial/fields/point.rb'

# Offense count: 6
Style/Documentation:
Exclude:
Expand All @@ -45,7 +70,8 @@ Style/Documentation:
- 'lib/mongoid/geospatial/config/point.rb'

# Offense count: 2
# Configuration parameters: EnforcedStyle, SupportedStyles.
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: module_function, extend_self
Style/ModuleFunction:
Exclude:
Expand All @@ -54,8 +80,14 @@ Style/ModuleFunction:

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
# SupportedStyles: slashes, percent_r, mixed
Style/RegexpLiteral:
Exclude:
- 'Guardfile'

# Offense count: 15
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 113
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -7,7 +7,7 @@ cache: bundler
services: mongodb

rvm:
- 2.3.1
- 2.5.3

before_install:
- gem update bundler
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -2,7 +2,7 @@

* [#61](https://github.com/mongoid/mongoid-geospatial/pull/64): Add global configuration for switching between LngLat and LatLng - [@dblock](https://github.com/dblock).
* [#59](https://github.com/mongoid/mongoid-geospatial/pull/59), [#65](https://github.com/mongoid/mongoid-geospatial/pull/65): Test against Mongoid 5, 6 and 7 - [@dblock](https://github.com/dblock).
* [#52](https://github.com/mongoid/mongoid-geospatial/pull/52): Added Danger and Rubocop, PR and code linters - [@dblock](https://github.com/dblock).
* [#52](https://github.com/mongoid/mongoid-geospatial/pull/52), [#70](https://github.com/mongoid/mongoid-geospatial/pull/70): Added Danger and Rubocop, PR and code linters - [@dblock](https://github.com/dblock).
* Your contribution here.

## 5.0.0 (2015/07/23)
Expand Down
18 changes: 9 additions & 9 deletions Gemfile
Expand Up @@ -16,22 +16,22 @@ end
gemspec

group :development, :test do
gem 'rake'
gem 'pry'
gem 'yard'
gem 'fuubar'
gem 'guard'
gem 'guard-rubocop'
gem 'guard-rspec'
gem 'guard-rubocop'
gem 'pry'
gem 'rake'
gem 'yard'
end

group :test do
gem 'nokogiri'
gem 'coveralls', require: false if ENV['CI']
gem 'dbf'
gem 'rgeo'
gem 'georuby'
gem 'rspec'
gem 'coveralls', require: false if ENV['CI']
gem 'mongoid-danger', '~> 0.1.0', require: false
gem 'rubocop', '0.45.0'
gem 'nokogiri'
gem 'rgeo'
gem 'rspec'
gem 'rubocop', '0.60.0'
end
2 changes: 1 addition & 1 deletion Rakefile 100644 → 100755
Expand Up @@ -15,6 +15,6 @@ end
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop)

task default: [:rubocop, :spec]
task default: %i[rubocop spec]

require 'yard'
2 changes: 1 addition & 1 deletion bench/bench
Expand Up @@ -2,7 +2,7 @@
#
# Just for fun
#
$LOAD_PATH << File.expand_path('../../lib', __FILE__)
$LOAD_PATH << File.expand_path('../lib', __dir__)

require 'mongoid/geospatial'

Expand Down
2 changes: 1 addition & 1 deletion lib/mongoid/geospatial.rb
Expand Up @@ -38,7 +38,7 @@ module Geospatial

# Earth radius in multiple units
EARTH_RADIUS = {
m: EARTH_RADIUS_KM * 1000,
m: EARTH_RADIUS_KM * 1000,
km: EARTH_RADIUS_KM,
mi: EARTH_RADIUS_KM * 0.621371192,
ft: EARTH_RADIUS_KM * 5280 * 0.621371192,
Expand Down
7 changes: 7 additions & 0 deletions lib/mongoid/geospatial/fields/point.rb
Expand Up @@ -18,6 +18,7 @@ def initialize(x, y, z = nil)
# @return (Array)
def mongoize
return nil unless x && y

[x, y]
end
alias to_a mongoize
Expand Down Expand Up @@ -144,6 +145,7 @@ def mongoize(obj)
when NilClass then nil
else
return obj.to_xy if obj.respond_to?(:to_xy)

raise 'Invalid Point'
end
end
Expand Down Expand Up @@ -171,6 +173,7 @@ def evolve(obj)
#
def from_string(str)
return nil if str.empty?

str.split(/,|\s/).reject(&:empty?).map(&:to_f)
end

Expand All @@ -185,6 +188,7 @@ def from_string(str)
#
def from_array(array)
return nil if array.empty?

array.flatten[0..1].map(&:to_f)
end

Expand All @@ -204,18 +208,21 @@ def from_array(array)
#
def from_hash(hsh)
raise 'Hash must have at least 2 items' if hsh.size < 2

[from_hash_x(hsh), from_hash_y(hsh)]
end

def from_hash_y(hsh)
v = (Mongoid::Geospatial::Config::Point.y & hsh.keys).first
return hsh[v].to_f if !v.nil? && hsh[v]

raise "Hash must contain #{Mongoid::Geospatial::Config::Point.y.inspect}"
end

def from_hash_x(hsh)
v = (Mongoid::Geospatial::Config::Point.x & hsh.keys).first
return hsh[v].to_f if !v.nil? && hsh[v]

raise "Hash must contain #{Mongoid::Geospatial::Config::Point.x.inspect}"
end
end # << self
Expand Down
1 change: 1 addition & 0 deletions lib/mongoid/geospatial/wrappers/georuby.rb
Expand Up @@ -16,6 +16,7 @@ module Geospatial
# @return (GeoRuby::SimpleFeatures::Point)
def to_geo
return unless valid?

GeoRuby::SimpleFeatures::Point.xy(x, y)
end

Expand Down
3 changes: 1 addition & 2 deletions mongoid-geospatial.gemspec
@@ -1,5 +1,4 @@
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/mongoid/geospatial/version', __FILE__)
require File.expand_path('lib/mongoid/geospatial/version', __dir__)

Gem::Specification.new do |gem|
gem.authors = ['Ryan Ong', 'Marcos Piccinini']
Expand Down
2 changes: 1 addition & 1 deletion spec/mongoid/geospatial/geospatial_spec.rb
Expand Up @@ -72,7 +72,7 @@
before do
Alarm.create_indexes
50.times do
Alarm.create(spot: [rand(10) + 1, rand(10) + 1])
Alarm.create(spot: [rand(1..10), rand(1..10)])
end
end

Expand Down
3 changes: 3 additions & 0 deletions spec/mongoid/geospatial/helpers/core_spec.rb
Expand Up @@ -6,12 +6,14 @@ def self.from_array(ary)

def self.from_hash(hsh)
raise 'Hash must have at least 2 items' if hsh.size < 2

[from_hash_x(hsh), from_hash_y(hsh)]
end

def self.from_hash_y(hsh)
v = (Mongoid::Geospatial.lat_symbols & hsh.keys).first
return hsh[v].to_f if !v.nil? && hsh[v]

if Mongoid::Geospatial.lng_symbols.index(hsh.keys[1])
raise "Hash cannot contain #{Mongoid::Geospatial.lng_symbols.inspect} "\
"as second arg without #{Mongoid::Geospatial.lat_symbols.inspect}"
Expand All @@ -22,6 +24,7 @@ def self.from_hash_y(hsh)
def self.from_hash_x(hsh)
v = (Mongoid::Geospatial.lng_symbols & hsh.keys).first
return hsh[v].to_f if !v.nil? && hsh[v]

if Mongoid::Geospatial.lat_symbols.index(keys[0])
raise "Hash cannot contain #{Mongoid::Geospatial.lat_symbols.inspect} "\
"as first arg without #{Mongoid::Geospatial.lng_symbols.inspect}"
Expand Down
1 change: 0 additions & 1 deletion spec/support/authentication.rb
@@ -1,4 +1,3 @@
# encoding: utf-8
module Support #:nodoc:
# module Authentication
# extend self
Expand Down

0 comments on commit de287d6

Please sign in to comment.