Skip to content

Commit

Permalink
Autofixing rubocop offenses and Problematic test for #578 (#667)
Browse files Browse the repository at this point in the history
* Autofixing rubocop offenses

* Adding Rubocop to Travis pipelines and development branch

* Fixing maps controller test

* Fixing remaining offenses
  • Loading branch information
alaxalves authored and cesswairimu committed Jun 7, 2019
1 parent 1d220ec commit 5bb19c2
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 234 deletions.
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"

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

2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ group :dependencies do
end

group :test do
gem "rubocop", '~> 0.64.0'
gem "rubocop", '~> 0.52.0'
gem 'ruby-prof'
gem 'rails-perftest'
gem 'simplecov', require: false
Expand Down
22 changes: 10 additions & 12 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 @@ -79,7 +79,6 @@ GEM
concurrent-ruby (~> 1.0)
image_science (1.3.0)
RubyInline (~> 3.9)
jaro_winkler (1.5.2)
jshintrb (0.3.0)
execjs
multi_json (>= 1.3)
Expand Down Expand Up @@ -176,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 All @@ -188,14 +187,13 @@ GEM
net-http-persistent (~> 2.9)
redcarpet (>= 3.0.0)
ruby-hmac (>= 0.4.0)
rubocop (0.64.0)
jaro_winkler (~> 1.5.1)
rubocop (0.52.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
parser (>= 2.4.0.2, < 3.0)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.4.0)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-hmac (0.4.0)
ruby-openid (2.7.0)
ruby-openid-apps-discovery (1.2.0)
Expand All @@ -214,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 All @@ -235,7 +233,7 @@ GEM
thread_safe (~> 0.1)
uglifier (4.1.20)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.4.1)
unicode-display_width (1.6.0)
uuidtools (2.1.5)
web-console (2.3.0)
activemodel (>= 4.0)
Expand Down Expand Up @@ -276,7 +274,7 @@ DEPENDENCIES
rdiscount (= 2.2.0.1)
recaptcha
right_aws_api
rubocop (~> 0.64.0)
rubocop (~> 0.52.0)
ruby-openid (~> 2.5)
ruby-prof
sass
Expand Down
2 changes: 1 addition & 1 deletion app/models/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ def self.export_count
# 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
4 changes: 2 additions & 2 deletions app/models/map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Map < ActiveRecord::Base
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 @@ -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
2 changes: 1 addition & 1 deletion app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Tag < ActiveRecord::Base
belongs_to :map
belongs_to :user

validates_presence_of :name, 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"

Expand Down
223 changes: 111 additions & 112 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,154 +9,153 @@
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(:version => 20190420025012) do
ActiveRecord::Schema.define(version: 20190420025012) do

create_table "annotations", :force => true do |t|
t.integer "map_id"
t.integer "user_id"
t.string "annotation_type"
t.string "text"
t.string "style"
t.string "coordinates"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
create_table "annotations", force: :cascade do |t|
t.integer "map_id", limit: 4
t.integer "user_id", limit: 4
t.string "annotation_type", limit: 255
t.string "text", limit: 255
t.string "style", limit: 255
t.string "coordinates", limit: 255
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "comments", :force => true do |t|
t.string "user_id"
t.string "body"
t.integer "map_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
create_table "comments", force: :cascade do |t|
t.string "user_id", limit: 255
t.string "body", limit: 255
t.integer "map_id", limit: 4
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "exports", :force => true do |t|
t.integer "map_id", :default => 0
t.integer "size", :default => 0
t.integer "width", :default => 0
t.integer "height", :default => 0
t.float "cm_per_pixel", :default => 0.0
t.string "status", :default => "none"
t.boolean "tms", :default => false
t.boolean "jpg", :default => false
t.boolean "geotiff", :default => false
create_table "exports", force: :cascade do |t|
t.integer "map_id", limit: 4, default: 0
t.integer "size", limit: 4, default: 0
t.integer "width", limit: 4, default: 0
t.integer "height", limit: 4, default: 0
t.float "cm_per_pixel", limit: 24, default: 0.0
t.string "status", limit: 255, default: "none"
t.boolean "tms", default: false
t.boolean "jpg", default: false
t.boolean "geotiff", default: false
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "zip", :default => false, :null => false
t.text "bands_string", :null => false
t.string "export_type", :default => "normal", :null => false
t.integer "user_id", :default => 0
t.string "export_url"
t.boolean "zip", default: false, null: false
t.text "bands_string", limit: 65535, null: false
t.string "export_type", limit: 255, default: "normal", null: false
t.integer "user_id", limit: 4, default: 0
t.string "export_url", limit: 255
end

create_table "maps", :force => true do |t|
t.string "name", :default => ""
t.decimal "lat", :precision => 20, :scale => 10, :default => 0.0
t.decimal "lon", :precision => 20, :scale => 10, :default => 0.0
t.integer "version", :default => 1
t.string "password", :default => ""
t.text "styles"
create_table "maps", force: :cascade do |t|
t.string "name", limit: 255, default: ""
t.decimal "lat", precision: 20, scale: 10, default: 0.0
t.decimal "lon", precision: 20, scale: 10, default: 0.0
t.integer "version", limit: 4, default: 1
t.string "password", limit: 255, default: ""
t.text "styles", limit: 65535
t.datetime "created_at"
t.datetime "updated_at"
t.text "description"
t.string "author", :default => "anonymous"
t.decimal "zoom", :precision => 15, :scale => 10, :default => 2.0
t.string "location", :default => ""
t.string "static_data", :default => ""
t.boolean "vectors", :default => false, :null => false
t.string "tiles", :default => "google", :null => false
t.string "email", :default => "", :null => false
t.boolean "archived", :default => false, :null => false
t.text "tile_url"
t.text "tile_layer"
t.string "license", :default => "copyright"
t.integer "user_id", :default => 0
t.boolean "anon_annotatable", :default => false
t.string "slug"
t.text "description", limit: 65535
t.string "author", limit: 255, default: "anonymous"
t.decimal "zoom", precision: 15, scale: 10, default: 2.0
t.string "location", limit: 255, default: ""
t.string "static_data", limit: 255, default: ""
t.boolean "vectors", default: false, null: false
t.string "tiles", limit: 255, default: "google", null: false
t.string "email", limit: 255, default: "", null: false
t.boolean "archived", default: false, null: false
t.text "tile_url", limit: 65535
t.text "tile_layer", limit: 65535
t.string "license", limit: 255, default: "copyright"
t.integer "user_id", limit: 4, default: 0
t.boolean "anon_annotatable", default: false
t.string "slug", limit: 255
end

add_index "maps", ["slug"], :name => "index_maps_on_slug", :unique => true
add_index "maps", ["slug"], name: "index_maps_on_slug", unique: true, using: :btree

create_table "nodes", :force => true do |t|
t.string "color", :default => "red"
t.string "author", :default => "anonymous"
t.decimal "lat", :precision => 20, :scale => 10, :default => 0.0
t.decimal "lon", :precision => 20, :scale => 10, :default => 0.0
t.integer "way_id", :default => 0
t.integer "order", :default => 0
create_table "nodes", force: :cascade do |t|
t.string "color", limit: 255, default: "red"
t.string "author", limit: 255, default: "anonymous"
t.decimal "lat", precision: 20, scale: 10, default: 0.0
t.decimal "lon", precision: 20, scale: 10, default: 0.0
t.integer "way_id", limit: 4, default: 0
t.integer "order", limit: 4, default: 0
t.datetime "created_at"
t.datetime "updated_at"
t.string "name", :default => ""
t.string "description", :default => ""
t.integer "map_id", :default => 0
t.integer "way_order", :default => 0
t.text "body"
t.string "name", limit: 255, default: ""
t.string "description", limit: 255, default: ""
t.integer "map_id", limit: 4, default: 0
t.integer "way_order", limit: 4, default: 0
t.text "body", limit: 65535
end

create_table "tags", :force => true do |t|
t.string "user_id"
t.string "name"
t.integer "map_id"
t.integer "warpable_id"
create_table "tags", force: :cascade do |t|
t.string "user_id", limit: 255
t.string "name", limit: 255
t.integer "map_id", limit: 4
t.integer "warpable_id", limit: 4
t.datetime "created_at"
t.datetime "updated_at"
end

add_index "tags", ["map_id"], :name => "index_tags_on_map_id"
add_index "tags", ["user_id"], :name => "index_tags_on_user_id"
add_index "tags", ["warpable_id"], :name => "index_tags_on_warpable_id"
add_index "tags", ["map_id"], name: "index_tags_on_map_id", using: :btree
add_index "tags", ["user_id"], name: "index_tags_on_user_id", using: :btree
add_index "tags", ["warpable_id"], name: "index_tags_on_warpable_id", using: :btree

create_table "users", :force => true do |t|
t.string "login", :limit => 40
t.string "name", :limit => 100, :default => ""
t.string "email", :limit => 100
t.string "crypted_password", :limit => 40
t.string "salt", :limit => 40
t.string "identity_url"
t.string "role", :limit => 40, :default => "basic"
create_table "users", force: :cascade do |t|
t.string "login", limit: 40
t.string "name", limit: 100, default: ""
t.string "email", limit: 100
t.string "crypted_password", limit: 40
t.string "salt", limit: 40
t.string "identity_url", limit: 255
t.string "role", limit: 40, default: "basic"
t.datetime "created_at"
t.datetime "updated_at"
t.string "remember_token", :limit => 40
t.string "remember_token", limit: 40
t.datetime "remember_token_expires_at"
end

add_index "users", ["login"], :name => "index_users_on_login", :unique => true
add_index "users", ["login"], name: "index_users_on_login", unique: true, using: :btree

create_table "warpables", :force => true do |t|
t.integer "parent_id"
t.string "image_content_type"
t.string "image_file_name"
t.string "thumbnail"
t.integer "image_file_size"
t.integer "width"
t.integer "height"
create_table "warpables", force: :cascade do |t|
t.integer "parent_id", limit: 4
t.string "image_content_type", limit: 255
t.string "image_file_name", limit: 255
t.string "thumbnail", limit: 255
t.integer "image_file_size", limit: 4
t.integer "width", limit: 4
t.integer "height", limit: 4
t.datetime "created_at"
t.datetime "updated_at"
t.integer "map_id", :default => 0
t.string "nodes", :default => ""
t.boolean "locked", :default => false, :null => false
t.boolean "deleted", :default => false, :null => false
t.text "history", :null => false
t.float "cm_per_pixel", :default => 0.0, :null => false
t.integer "map_id", limit: 4, default: 0
t.string "nodes", limit: 255, default: ""
t.boolean "locked", default: false, null: false
t.boolean "deleted", default: false, null: false
t.text "history", limit: 65535, null: false
t.float "cm_per_pixel", limit: 24, default: 0.0, null: false
end

create_table "ways", :force => true do |t|
t.string "color", :default => "red"
t.string "author", :default => "anonymous"
t.decimal "lat1", :precision => 20, :scale => 10, :default => 0.0
t.decimal "lat2", :precision => 20, :scale => 10, :default => 0.0
t.decimal "lon1", :precision => 20, :scale => 10, :default => 0.0
t.decimal "lon2", :precision => 20, :scale => 10, :default => 0.0
create_table "ways", force: :cascade do |t|
t.string "color", limit: 255, default: "red"
t.string "author", limit: 255, default: "anonymous"
t.decimal "lat1", precision: 20, scale: 10, default: 0.0
t.decimal "lat2", precision: 20, scale: 10, default: 0.0
t.decimal "lon1", precision: 20, scale: 10, default: 0.0
t.decimal "lon2", precision: 20, scale: 10, default: 0.0
t.datetime "created_at"
t.datetime "updated_at"
t.string "name", :default => ""
t.string "description", :default => ""
t.boolean "complete", :default => true
t.integer "map_id", :default => 0
t.text "body"
t.string "name", limit: 255, default: ""
t.string "description", limit: 255, default: ""
t.boolean "complete", default: true
t.integer "map_id", limit: 4, default: 0
t.text "body", limit: 65535
end

end

Loading

0 comments on commit 5bb19c2

Please sign in to comment.