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

Autofixing rubocop offenses and Problematic test for #578 #667

Merged
merged 5 commits into from
Jun 6, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ env:
- TASK="CI=true TRAVIS=true rake test:integration"
- TASK="CI=true TRAVIS=true rake test:functional"
- TASK="CI=true TRAVIS=true rake assets:precompile"
- TASK="CI=true TRAVIS=true bundle exec rubocop"
Copy link
Member

Choose a reason for hiding this comment

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

I still dislike the idea of Rubocop blocking travis builds :/

Copy link
Member Author

Choose a reason for hiding this comment

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

We need to have those since I have got rubocop synch'd with CodeClimate, we're getting a wider view of our PR statuses.


script:
- docker-compose -f docker-compose.test.yml exec web bash -lc "$TASK"
Expand All @@ -34,4 +35,5 @@ branches:
only:
- main
- unstable
- development

10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ GEM
ansi (1.5.0)
arel (6.0.4)
ast (2.4.0)
autoprefixer-rails (9.5.1.1)
autoprefixer-rails (9.6.0)
execjs
aws-sdk (1.5.8)
httparty (~> 0.7)
Expand Down Expand Up @@ -175,7 +175,7 @@ GEM
rb-inotify (0.10.0)
ffi (~> 1.0)
rdiscount (2.2.0.1)
recaptcha (4.14.0)
recaptcha (5.0.0)
json
redcarpet (3.4.0)
ref (2.0.0)
Expand Down Expand Up @@ -212,9 +212,9 @@ GEM
simplecov-cobertura (1.3.1)
simplecov (~> 0.8)
simplecov-html (0.10.2)
skylight (4.0.2)
skylight-core (= 4.0.2)
skylight-core (4.0.2)
skylight (4.1.0)
skylight-core (= 4.1.0)
skylight-core (4.1.0)
activesupport (>= 4.2.0)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/annotations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def update
return if @annotation.user_id.nil? || current_user.can_edit?(@annotation)

Annotation.update(@annotation.id,
coordinates: geojson[:geometry][:coordinates],
text: geojson[:properties][:textContent],
style: geojson[:properties][:style])
coordinates: geojson[:geometry][:coordinates],
text: geojson[:properties][:textContent],
style: geojson[:properties][:style])
render file: 'annotations/update.json.erb',
content_type: 'application/json'
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/feeds_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class FeedsController < ApplicationController
def all
# (Warpable.all + Map.all).sort_by(&:created_at)
@maps = Map.where(archived: false, password: '')
.joins(%i[user warpables])
.joins(%i(user warpables))
.group('maps.id')
.order('id DESC')
.limit(20)
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/maps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
class MapsController < ApplicationController
protect_from_forgery except: :export

before_filter :require_login, only: %i[edit update destroy]
before_filter :find_map, only: %i[show annotate embed edit update images destroy archive]
before_filter :require_login, only: %i(edit update destroy)
before_filter :find_map, only: %i(show annotate embed edit update images destroy archive)

layout 'knitter2'

Expand Down Expand Up @@ -77,7 +77,7 @@ def archive
else
flash[:error] = 'Only admins may archive maps.'
end
redirect_to "/?_=#{Time.now.to_i.to_s}"
redirect_to "/?_=#{Time.now.to_i}"
end

def embed
Expand All @@ -100,7 +100,7 @@ def update
# @map.lon = params[:map][:lon]
# @map.description = params[:map][:description]
# @map.license = params[:map][:license] if @map.user_id == current_user.id
@map.update_attributes(map_params)
@map.update_attributes(map_params)

save_tags(@map)
@map.save
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ def sort_direction

def user_params
params.require(:user).permit(:login, :email, :name,
:password, :password_confirmation)
:password, :password_confirmation)
end
end
2 changes: 1 addition & 1 deletion app/models/annotation.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Annotation < ActiveRecord::Base
include ActiveModel::MassAssignmentSecurity
include ActiveModel::MassAssignmentSecurity
belongs_to :map
belongs_to :user

Expand Down
1 change: 0 additions & 1 deletion app/models/comment.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class Comment < ActiveRecord::Base

belongs_to :map
belongs_to :user

Expand Down
4 changes: 2 additions & 2 deletions app/models/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ def self.histogram_cm_per_pixel_in_tens

def self.export_count
Export.where('status != "failed" AND status != "complete" AND status != "none" AND updated_at > ?',
(DateTime.now-24.hours).to_s(:db)).count
(DateTime.now - 24.hours).to_s(:db)).count
end

# all exports currently running
def self.exporting
Export.where('status != "failed" AND status != "complete" AND status != "none" AND updated_at > ?',
(DateTime.now-24.hours).to_s(:db))
(DateTime.now - 24.hours).to_s(:db))
end
end
22 changes: 11 additions & 11 deletions app/models/map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ class Map < ActiveRecord::Base

validates_presence_of :name, :slug, :author, :lat, :lon
validates_uniqueness_of :slug
validates_presence_of :location, :message => ' cannot be found. Try entering a latitude and longitude if this problem persists.'
validates_presence_of :location, message: ' cannot be found. Try entering a latitude and longitude if this problem persists.'
# validates_format_of :slug,
# :with => /^[\w-]*$/,
# :message => " must not include spaces and must be alphanumeric, as it'll be used in the URL of your map, like: https://mapknitter.org/maps/your-map-name. You may use dashes and underscores.",
# :on => :create
# validates_format_of :tile_url, :with => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/ix
# validates_format_of :tile_url, :with => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/ix
validates_with NotAtOriginValidator
validates :lat, :lon, NotAtOrigin: true
validates :lat, :lon, NotAtOrigin: true

has_many :exports, :dependent => :destroy
has_many :tags, :dependent => :destroy
has_many :comments, :dependent => :destroy
has_many :annotations, :dependent => :destroy
has_many :exports, dependent: :destroy
has_many :tags, dependent: :destroy
has_many :comments, dependent: :destroy
has_many :annotations, dependent: :destroy
belongs_to :user

has_many :warpables
has_many :warpables
scope :active, -> { where(archived: false) }
scope :has_user, -> { where('user_id != ?', 0) }

Expand Down Expand Up @@ -87,7 +87,7 @@ def self.featured
end

def self.new_maps
Map.where( ['password = "" AND archived = "false"'])
Map.where(['password = "" AND archived = "false"'])
.order('created_at DESC')
.limit(12)
end
Expand Down Expand Up @@ -140,7 +140,7 @@ def nearby_maps(dist)
return [] if lat.to_f == 0.0 || lon.to_f == 0.0

Map.where('id != ? AND lat > ? AND lat < ? AND lon > ? AND lon < ?',
id, lat - dist, lat + dist, lon - dist, lon + dist)
id, lat - dist, lat + dist, lon - dist, lon + dist)
.limit(10)
end

Expand Down Expand Up @@ -254,7 +254,7 @@ def license_link
end

def has_tag(tagname)
!Tag.where(map_id: self.id, name: tagname).empty?
!Tag.where(map_id: id, name: tagname).empty?
end

def add_tag(tagname, user)
Expand Down
6 changes: 3 additions & 3 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ class Tag < ActiveRecord::Base
belongs_to :map
belongs_to :user

validates_presence_of :name, :on => :create, :message => "can't be blank"
validates_presence_of :user_id, :on => :create, :message => "can't be blank"
validates_presence_of :map_id, :on => :create, :message => "can't be blank"
validates_presence_of :name, on: :create, message: "can't be blank"
validates_presence_of :user_id, on: :create, message: "can't be blank"
validates_presence_of :map_id, on: :create, message: "can't be blank"

def maps
Map.where(id: Tag.where(name: name).collect(&:map_id).uniq)
Expand Down
2 changes: 1 addition & 1 deletion app/models/warpable.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Warpable < ActiveRecord::Base
include ActiveModel::MassAssignmentSecurity
include ActiveModel::MassAssignmentSecurity
attr_accessible :image
attr_accessor :src, :srcmedium # for json generation

Expand Down
2 changes: 1 addition & 1 deletion app/models/way.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Way < ActiveRecord::Base
has_many :nodes, :dependent => :destroy
has_many :nodes, dependent: :destroy

def bbox=(bbox)
# counting from left, counter-clockwise
Expand Down
Loading