mirror of
https://github.com/publiclab/mapknitter.git
synced 2025-12-05 16:00:00 +01:00
remove local codecov reports & rubocop offenses fixes (#1776)
* remove codecov local * rubocop offenses fixes
This commit is contained in:
62
.rubocop.yml
62
.rubocop.yml
@@ -84,3 +84,65 @@ Layout/LineLength:
|
||||
|
||||
Style/Documentation:
|
||||
Enabled: false
|
||||
|
||||
Style/SymbolArray:
|
||||
Enabled: true
|
||||
EnforcedStyle: percent
|
||||
|
||||
Style/WordArray:
|
||||
Enabled: true
|
||||
EnforcedStyle: percent
|
||||
|
||||
Performance/AncestorsInclude: # new in 1.7
|
||||
Enabled: true
|
||||
|
||||
Performance/BigDecimalWithNumericArgument: # new in 1.7
|
||||
Enabled: true
|
||||
|
||||
Performance/BlockGivenWithExplicitBlock: # new in 1.9
|
||||
Enabled: true
|
||||
|
||||
Performance/CollectionLiteralInLoop: # new in 1.8
|
||||
Enabled: true
|
||||
|
||||
Performance/ConcurrentMonotonicTime: # new in 1.12
|
||||
Enabled: true
|
||||
|
||||
Performance/ConstantRegexp: # new in 1.9
|
||||
Enabled: true
|
||||
|
||||
Performance/MapCompact: # new in 1.11
|
||||
Enabled: true
|
||||
|
||||
Performance/MethodObjectAsBlock: # new in 1.9
|
||||
Enabled: true
|
||||
|
||||
Performance/RedundantEqualityComparisonBlock: # new in 1.10
|
||||
Enabled: true
|
||||
|
||||
Performance/RedundantSortBlock: # new in 1.7
|
||||
Enabled: true
|
||||
|
||||
Performance/RedundantSplitRegexpArgument: # new in 1.10
|
||||
Enabled: true
|
||||
|
||||
Performance/RedundantStringChars: # new in 1.7
|
||||
Enabled: true
|
||||
|
||||
Performance/ReverseFirst: # new in 1.7
|
||||
Enabled: true
|
||||
|
||||
Performance/SortReverse: # new in 1.7
|
||||
Enabled: true
|
||||
|
||||
Performance/Squeeze: # new in 1.7
|
||||
Enabled: true
|
||||
|
||||
Performance/StringIdentifierArgument: # new in 1.13
|
||||
Enabled: true
|
||||
|
||||
Performance/StringInclude: # new in 1.7
|
||||
Enabled: true
|
||||
|
||||
Performance/Sum: # new in 1.8
|
||||
Enabled: true
|
||||
|
||||
@@ -24,7 +24,7 @@ class SpamController < ApplicationController
|
||||
include ModerationGuards
|
||||
|
||||
before_action :require_login
|
||||
before_action { logged_in_as(['admin', 'moderator'], 'moderate maps and users') }
|
||||
before_action { logged_in_as(%w[admin moderator], 'moderate maps and users') }
|
||||
|
||||
def spam_map
|
||||
@map = Map.find(params[:id])
|
||||
|
||||
@@ -16,7 +16,7 @@ class TagsController < ApplicationController
|
||||
@tag = Tag.find_by_name(params[:id])
|
||||
@maps = @tag.maps.paginate(page: params[:page], per_page: 24)
|
||||
@title = "Maps tagged with ' #{@tag.name} '"
|
||||
tag = Tag.where(name: 'featured').first # note that this is not a join table but the .maps method still works
|
||||
tag = Tag.where(name: 'featured').first # NOTE: that this is not a join table but the .maps method still works
|
||||
@unpaginated = true
|
||||
@authors = User.where(login: tag.maps.collect(&:author)) if tag
|
||||
@authors ||= []
|
||||
|
||||
@@ -62,10 +62,10 @@ class Map < ApplicationRecord
|
||||
def self.bbox(minlat, minlon, maxlat, maxlon, tag = nil)
|
||||
if tag.nil?
|
||||
Map.where(['lat > ? AND lat < ? AND lon > ? AND lon < ?',
|
||||
minlat, maxlat, minlon, maxlon])
|
||||
minlat, maxlat, minlon, maxlon,])
|
||||
else
|
||||
Map.where(['lat > ? AND lat < ? AND lon > ? AND lon < ?',
|
||||
minlat, maxlat, minlon, maxlon])
|
||||
minlat, maxlat, minlon, maxlon,])
|
||||
.joins(:tags).where("tags.name = ?", tag)
|
||||
end
|
||||
end
|
||||
@@ -91,10 +91,10 @@ class Map < ApplicationRecord
|
||||
|
||||
def self.search(query)
|
||||
query = query.squeeze(' ').strip
|
||||
Map.active
|
||||
.where(['author LIKE ? OR name LIKE ?
|
||||
OR location LIKE ? OR description LIKE ?',
|
||||
"%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%"])
|
||||
Map.active.where([
|
||||
'author LIKE ? OR name LIKE ? OR location LIKE ? OR description LIKE ?',
|
||||
"%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%",
|
||||
])
|
||||
end
|
||||
|
||||
def self.featured
|
||||
@@ -132,9 +132,10 @@ class Map < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.maps_nearby(lat:, lon:, dist:)
|
||||
Map.active
|
||||
.where(['lat>? AND lat<? AND lon>? AND lon<?',
|
||||
lat - dist, lat + dist, lon - dist, lon + dist])
|
||||
Map.active.where([
|
||||
'lat>? AND lat<? AND lon>? AND lon<?',
|
||||
lat - dist, lat + dist, lon - dist, lon + dist,
|
||||
])
|
||||
end
|
||||
|
||||
def nodes
|
||||
@@ -169,8 +170,7 @@ class Map < ApplicationRecord
|
||||
placed_warpables.each do |warpable|
|
||||
pxperms << 100.00 / warpable.cm_per_pixel if warpable.placed?
|
||||
end
|
||||
average = (pxperms.inject { |sum, n| sum + n }) / pxperms.length
|
||||
average
|
||||
pxperms.sum / pxperms.length
|
||||
end
|
||||
|
||||
def best_cm_per_pixel
|
||||
@@ -202,7 +202,7 @@ class Map < ApplicationRecord
|
||||
res = 1 if res.zero? # let's not ever try to go for infinite resolution
|
||||
scales << res unless res.nil?
|
||||
end
|
||||
total_sum = (scales.inject { |sum, n| sum + n }) if scales
|
||||
total_sum = scales.sum unless scales.empty?
|
||||
average = total_sum / count if total_sum
|
||||
average
|
||||
else
|
||||
|
||||
@@ -19,7 +19,7 @@ class Warpable < ApplicationRecord
|
||||
belongs_to :map, optional: true
|
||||
belongs_to :user, optional: true
|
||||
|
||||
has_paper_trail on: %i(create update), only: %i(nodes)
|
||||
has_paper_trail on: %i(create update), only: :nodes
|
||||
|
||||
# overriding JSON formatting for Leaflet.DistortableImage
|
||||
def as_json(options = {})
|
||||
@@ -32,20 +32,24 @@ class Warpable < ApplicationRecord
|
||||
|
||||
# JSON formatting for file upload plugin
|
||||
def fup_json
|
||||
{ "name" => read_attribute(:image_filename),
|
||||
{
|
||||
"name" => read_attribute(:image_filename),
|
||||
"size" => read_attribute(:image_size),
|
||||
"url" => image.url(:medium),
|
||||
"original_url" => image.url(:original),
|
||||
"id" => read_attribute(:id),
|
||||
"thumbnail_url" => image.url(:thumb),
|
||||
"delete_url" => image.url,
|
||||
"delete_type" => "DELETE" }
|
||||
"delete_type" => "DELETE",
|
||||
}
|
||||
end
|
||||
|
||||
def fup_error_json
|
||||
{ "name" => read_attribute(:image_filename),
|
||||
{
|
||||
"name" => read_attribute(:image_filename),
|
||||
"size" => read_attribute(:image_size),
|
||||
"error" => errors["base"] }
|
||||
"error" => errors["base"],
|
||||
}
|
||||
end
|
||||
|
||||
after_save :save_dimensions
|
||||
@@ -135,14 +139,17 @@ class Warpable < ApplicationRecord
|
||||
# needs update for Paperclip!!
|
||||
require 'open-uri'
|
||||
attr_reader :url
|
||||
|
||||
def url=(uri)
|
||||
nil if uri.blank?
|
||||
|
||||
io = (begin
|
||||
io = (
|
||||
begin
|
||||
URI.parse(uri).open
|
||||
rescue StandardError
|
||||
nil
|
||||
end)
|
||||
end
|
||||
)
|
||||
(class << io; self; end;).class_eval do
|
||||
define_method(:original_filename) { base_uri.path.split('/').last }
|
||||
end
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
|
||||
require_relative '../config/environment'
|
||||
require 'simplecov'
|
||||
require 'codecov'
|
||||
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
||||
|
||||
if ENV['CI'] == 'true'
|
||||
require 'codecov'
|
||||
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
||||
end
|
||||
|
||||
SimpleCov.start
|
||||
|
||||
require "rack_session_access/capybara"
|
||||
|
||||
Reference in New Issue
Block a user