Merge pull request #5598 from consuldemocracy/dependabot/bundler/rubocop-rails-2.25.1
Bump rubocop-rails from 2.23.1 to 2.25.1
This commit is contained in:
@@ -517,6 +517,9 @@ Rails/WhereNot:
|
|||||||
Rails/WhereNotWithMultipleConditions:
|
Rails/WhereNotWithMultipleConditions:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
Rails/WhereRange:
|
||||||
|
Enabled: true
|
||||||
|
|
||||||
RSpec/AroundBlock:
|
RSpec/AroundBlock:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
|||||||
2
Gemfile
2
Gemfile
@@ -102,7 +102,7 @@ group :development do
|
|||||||
gem "rubocop-capybara", "~> 2.21.0", require: false
|
gem "rubocop-capybara", "~> 2.21.0", require: false
|
||||||
gem "rubocop-factory_bot", "~> 2.26.1", require: false
|
gem "rubocop-factory_bot", "~> 2.26.1", require: false
|
||||||
gem "rubocop-performance", "~> 1.21.1", require: false
|
gem "rubocop-performance", "~> 1.21.1", require: false
|
||||||
gem "rubocop-rails", "~> 2.23.1", require: false
|
gem "rubocop-rails", "~> 2.25.1", require: false
|
||||||
gem "rubocop-rspec", "~> 2.27.0", require: false
|
gem "rubocop-rspec", "~> 2.27.0", require: false
|
||||||
gem "rvm1-capistrano3", "~> 1.4.0", require: false
|
gem "rvm1-capistrano3", "~> 1.4.0", require: false
|
||||||
gem "spring", "~> 4.2.1"
|
gem "spring", "~> 4.2.1"
|
||||||
|
|||||||
@@ -556,11 +556,11 @@ GEM
|
|||||||
rubocop-performance (1.21.1)
|
rubocop-performance (1.21.1)
|
||||||
rubocop (>= 1.48.1, < 2.0)
|
rubocop (>= 1.48.1, < 2.0)
|
||||||
rubocop-ast (>= 1.31.1, < 2.0)
|
rubocop-ast (>= 1.31.1, < 2.0)
|
||||||
rubocop-rails (2.23.1)
|
rubocop-rails (2.25.1)
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
rack (>= 1.1)
|
rack (>= 1.1)
|
||||||
rubocop (>= 1.33.0, < 2.0)
|
rubocop (>= 1.33.0, < 2.0)
|
||||||
rubocop-ast (>= 1.30.0, < 2.0)
|
rubocop-ast (>= 1.31.1, < 2.0)
|
||||||
rubocop-rspec (2.27.0)
|
rubocop-rspec (2.27.0)
|
||||||
rubocop (~> 1.40)
|
rubocop (~> 1.40)
|
||||||
rubocop-capybara (~> 2.17)
|
rubocop-capybara (~> 2.17)
|
||||||
@@ -769,7 +769,7 @@ DEPENDENCIES
|
|||||||
rubocop-capybara (~> 2.21.0)
|
rubocop-capybara (~> 2.21.0)
|
||||||
rubocop-factory_bot (~> 2.26.1)
|
rubocop-factory_bot (~> 2.26.1)
|
||||||
rubocop-performance (~> 1.21.1)
|
rubocop-performance (~> 1.21.1)
|
||||||
rubocop-rails (~> 2.23.1)
|
rubocop-rails (~> 2.25.1)
|
||||||
rubocop-rspec (~> 2.27.0)
|
rubocop-rspec (~> 2.27.0)
|
||||||
rvm1-capistrano3 (~> 1.4.0)
|
rvm1-capistrano3 (~> 1.4.0)
|
||||||
sassc-embedded (~> 1.70.1)
|
sassc-embedded (~> 1.70.1)
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ module ScoreCalculator
|
|||||||
|
|
||||||
period = [1, [max_period, resource_age(resource)].min].max
|
period = [1, [max_period, resource_age(resource)].min].max
|
||||||
|
|
||||||
votes_total = resource.votes_for.where("created_at >= ?", period.days.ago).count
|
votes_total = resource.votes_for.where(created_at: period.days.ago..).count
|
||||||
votes_up = resource.get_upvotes.where("created_at >= ?", period.days.ago).count
|
votes_up = resource.get_upvotes.where(created_at: period.days.ago..).count
|
||||||
votes_down = votes_total - votes_up
|
votes_down = votes_total - votes_up
|
||||||
votes_score = votes_up - votes_down
|
votes_score = votes_up - votes_down
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class Banner < ApplicationRecord
|
|||||||
has_many :sections
|
has_many :sections
|
||||||
has_many :web_sections, through: :sections
|
has_many :web_sections, through: :sections
|
||||||
|
|
||||||
scope :with_active, -> { where("post_started_at <= :date and post_ended_at >= :date", date: Date.current) }
|
scope :with_active, -> { where(post_started_at: ..Date.current, post_ended_at: Date.current..) }
|
||||||
scope :with_inactive, -> { where.not(id: with_active) }
|
scope :with_inactive, -> { where.not(id: with_active) }
|
||||||
scope :in_section, ->(section_name) do
|
scope :in_section, ->(section_name) do
|
||||||
joins(:web_sections, :sections).where("web_sections.name ilike ?", section_name)
|
joins(:web_sections, :sections).where("web_sections.name ilike ?", section_name)
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ class Budget
|
|||||||
scope :without_valuator, -> { without_valuator_group.where(valuator_assignments_count: 0) }
|
scope :without_valuator, -> { without_valuator_group.where(valuator_assignments_count: 0) }
|
||||||
scope :under_valuation, -> { valuation_open.valuating.with_admin }
|
scope :under_valuation, -> { valuation_open.valuating.with_admin }
|
||||||
scope :managed, -> { valuation_open.where(valuator_assignments_count: 0).with_admin }
|
scope :managed, -> { valuation_open.where(valuator_assignments_count: 0).with_admin }
|
||||||
scope :with_valuator_assignments, -> { where("valuator_assignments_count > 0") }
|
scope :with_valuator_assignments, -> { where(valuator_assignments_count: 1..) }
|
||||||
scope :with_group_assignments, -> { where("valuator_group_assignments_count > 0") }
|
scope :with_group_assignments, -> { where(valuator_group_assignments_count: 1..) }
|
||||||
scope :with_valuation_assignments, -> { with_valuator_assignments.or(with_group_assignments) }
|
scope :with_valuation_assignments, -> { with_valuator_assignments.or(with_group_assignments) }
|
||||||
scope :valuating, -> { valuation_open.with_valuation_assignments }
|
scope :valuating, -> { valuation_open.with_valuation_assignments }
|
||||||
scope :visible_to_valuators, -> { where(visible_to_valuators: true) }
|
scope :visible_to_valuators, -> { where(visible_to_valuators: true) }
|
||||||
@@ -90,13 +90,13 @@ class Budget
|
|||||||
scope :not_unfeasible, -> { where.not(feasibility: "unfeasible") }
|
scope :not_unfeasible, -> { where.not(feasibility: "unfeasible") }
|
||||||
scope :undecided, -> { where(feasibility: "undecided") }
|
scope :undecided, -> { where(feasibility: "undecided") }
|
||||||
|
|
||||||
scope :with_supports, -> { where("cached_votes_up > 0") }
|
scope :with_supports, -> { where(cached_votes_up: 1..) }
|
||||||
scope :selected, -> { feasible.where(selected: true) }
|
scope :selected, -> { feasible.where(selected: true) }
|
||||||
scope :compatible, -> { where(incompatible: false) }
|
scope :compatible, -> { where(incompatible: false) }
|
||||||
scope :incompatible, -> { where(incompatible: true) }
|
scope :incompatible, -> { where(incompatible: true) }
|
||||||
scope :winners, -> { selected.compatible.where(winner: true) }
|
scope :winners, -> { selected.compatible.where(winner: true) }
|
||||||
scope :unselected, -> { not_unfeasible.where(selected: false) }
|
scope :unselected, -> { not_unfeasible.where(selected: false) }
|
||||||
scope :last_week, -> { where("created_at >= ?", 7.days.ago) }
|
scope :last_week, -> { where(created_at: 7.days.ago..) }
|
||||||
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||||
scope :sort_by_created_at, -> { reorder(created_at: :desc) }
|
scope :sort_by_created_at, -> { reorder(created_at: :desc) }
|
||||||
scope :sort_by_ballot_lines, -> { order(:"budget_ballot_lines.created_at") }
|
scope :sort_by_ballot_lines, -> { order(:"budget_ballot_lines.created_at") }
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class Budget::Stats
|
|||||||
end
|
end
|
||||||
|
|
||||||
def balloters
|
def balloters
|
||||||
@balloters ||= budget.ballots.where("ballot_lines_count > ?", 0).distinct.pluck(:user_id).compact
|
@balloters ||= budget.ballots.where(ballot_lines_count: 1..).distinct.pluck(:user_id).compact
|
||||||
end
|
end
|
||||||
|
|
||||||
def poll_ballot_voters
|
def poll_ballot_voters
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ module Flaggable
|
|||||||
|
|
||||||
included do
|
included do
|
||||||
has_many :flags, as: :flaggable, inverse_of: :flaggable
|
has_many :flags, as: :flaggable, inverse_of: :flaggable
|
||||||
scope :flagged, -> { where("flags_count > 0") }
|
scope :flagged, -> { where(flags_count: 1..) }
|
||||||
scope :pending_flag_review, -> { flagged.where(ignored_flag_at: nil, hidden_at: nil) }
|
scope :pending_flag_review, -> { flagged.where(ignored_flag_at: nil, hidden_at: nil) }
|
||||||
scope :with_ignored_flag, -> { flagged.where.not(ignored_flag_at: nil).where(hidden_at: nil) }
|
scope :with_ignored_flag, -> { flagged.where.not(ignored_flag_at: nil).where(hidden_at: nil) }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ module Verification
|
|||||||
residence_or_phone_unverified.where(verified_at: nil, level_two_verified_at: nil)
|
residence_or_phone_unverified.where(verified_at: nil, level_two_verified_at: nil)
|
||||||
end
|
end
|
||||||
scope :incomplete_verification, -> do
|
scope :incomplete_verification, -> do
|
||||||
residence_unverified.where("failed_census_calls_count > ?", 0)
|
residence_unverified.where(failed_census_calls_count: 1..)
|
||||||
.or(residence_verified.phone_not_fully_confirmed)
|
.or(residence_verified.phone_not_fully_confirmed)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ class Dashboard::Action < ApplicationRecord
|
|||||||
def self.active_for(proposal)
|
def self.active_for(proposal)
|
||||||
published_at = proposal.published_at&.to_date || Date.current
|
published_at = proposal.published_at&.to_date || Date.current
|
||||||
|
|
||||||
active.where("required_supports <= ?", proposal.cached_votes_up)
|
active.where(required_supports: ..proposal.cached_votes_up)
|
||||||
.where("day_offset <= ?", (Date.current - published_at).to_i)
|
.where(day_offset: ..(Date.current - published_at).to_i)
|
||||||
.by_proposal(proposal)
|
.by_proposal(proposal)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -105,12 +105,12 @@ class Dashboard::Action < ApplicationRecord
|
|||||||
|
|
||||||
def self.calculate_actions(proposal_votes, day_offset, proposal)
|
def self.calculate_actions(proposal_votes, day_offset, proposal)
|
||||||
Dashboard::Action.active
|
Dashboard::Action.active
|
||||||
.where("required_supports <= ?", proposal_votes)
|
.where(required_supports: ..proposal_votes)
|
||||||
.where("day_offset <= ?", day_offset)
|
.where(day_offset: ..day_offset)
|
||||||
.by_published_proposal(proposal.published?)
|
.by_published_proposal(proposal.published?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.calculate_votes(proposal, date)
|
def self.calculate_votes(proposal, date)
|
||||||
Vote.where(votable: proposal).where("created_at <= ?", date).count
|
Vote.where(votable: proposal).where(created_at: ..date).count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class Debate < ApplicationRecord
|
|||||||
scope :sort_by_relevance, -> { all }
|
scope :sort_by_relevance, -> { all }
|
||||||
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||||
scope :sort_by_recommendations, -> { order(cached_votes_total: :desc) }
|
scope :sort_by_recommendations, -> { order(cached_votes_total: :desc) }
|
||||||
scope :last_week, -> { where("created_at >= ?", 7.days.ago) }
|
scope :last_week, -> { where(created_at: 7.days.ago..) }
|
||||||
scope :featured, -> { where.not(featured_at: nil) }
|
scope :featured, -> { where.not(featured_at: nil) }
|
||||||
scope :public_for_api, -> { all }
|
scope :public_for_api, -> { all }
|
||||||
|
|
||||||
|
|||||||
@@ -59,9 +59,9 @@ class Legislation::Process < ApplicationRecord
|
|||||||
validates :font_color, format: { allow_blank: true, with: ->(*) { CSS_HEX_COLOR }}
|
validates :font_color, format: { allow_blank: true, with: ->(*) { CSS_HEX_COLOR }}
|
||||||
|
|
||||||
class << self; undef :open; end
|
class << self; undef :open; end
|
||||||
scope :open, -> { where("start_date <= ? and end_date >= ?", Date.current, Date.current) }
|
scope :active, -> { where(end_date: Date.current..) }
|
||||||
scope :active, -> { where("end_date >= ?", Date.current) }
|
scope :open, -> { active.where(start_date: ..Date.current) }
|
||||||
scope :past, -> { where("end_date < ?", Date.current) }
|
scope :past, -> { where(end_date: ...Date.current) }
|
||||||
|
|
||||||
scope :published, -> { where(published: true) }
|
scope :published, -> { where(published: true) }
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class Legislation::Proposal < ApplicationRecord
|
|||||||
scope :sort_by_id, -> { reorder(id: :asc) }
|
scope :sort_by_id, -> { reorder(id: :asc) }
|
||||||
scope :sort_by_supports, -> { reorder(cached_votes_score: :desc) }
|
scope :sort_by_supports, -> { reorder(cached_votes_score: :desc) }
|
||||||
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||||
scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago) }
|
scope :last_week, -> { where(created_at: 7.days.ago..) }
|
||||||
scope :selected, -> { where(selected: true) }
|
scope :selected, -> { where(selected: true) }
|
||||||
scope :winners, -> { selected.sort_by_confidence_score }
|
scope :winners, -> { selected.sort_by_confidence_score }
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class Milestone < ApplicationRecord
|
|||||||
validates_translation :description, presence: true, unless: -> { status_id.present? }
|
validates_translation :description, presence: true, unless: -> { status_id.present? }
|
||||||
|
|
||||||
scope :order_by_publication_date, -> { order(publication_date: :asc, created_at: :asc) }
|
scope :order_by_publication_date, -> { order(publication_date: :asc, created_at: :asc) }
|
||||||
scope :published, -> { where("publication_date <= ?", Date.current.end_of_day) }
|
scope :published, -> { where(publication_date: ..Date.current.end_of_day) }
|
||||||
scope :with_status, -> { where.not(status_id: nil) }
|
scope :with_status, -> { where.not(status_id: nil) }
|
||||||
|
|
||||||
def self.title_max_length
|
def self.title_max_length
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ class Poll < ApplicationRecord
|
|||||||
accepts_nested_attributes_for :questions, reject_if: :all_blank, allow_destroy: true
|
accepts_nested_attributes_for :questions, reject_if: :all_blank, allow_destroy: true
|
||||||
|
|
||||||
scope :for, ->(element) { where(related: element) }
|
scope :for, ->(element) { where(related: element) }
|
||||||
scope :current, -> { where("starts_at <= :time and ends_at >= :time", time: Time.current) }
|
scope :current, -> { where(starts_at: ..Time.current, ends_at: Time.current..) }
|
||||||
scope :expired, -> { where("ends_at < ?", Time.current) }
|
scope :expired, -> { where(ends_at: ...Time.current) }
|
||||||
scope :recounting, -> { where(ends_at: (RECOUNT_DURATION.ago)...Time.current) }
|
scope :recounting, -> { where(ends_at: (RECOUNT_DURATION.ago)...Time.current) }
|
||||||
scope :published, -> { where(published: true) }
|
scope :published, -> { where(published: true) }
|
||||||
scope :by_geozone_id, ->(geozone_id) { where(geozones: { id: geozone_id }.joins(:geozones)) }
|
scope :by_geozone_id, ->(geozone_id) { where(geozones: { id: geozone_id }.joins(:geozones)) }
|
||||||
|
|||||||
@@ -75,13 +75,13 @@ class Proposal < ApplicationRecord
|
|||||||
scope :sort_by_archival_date, -> { archived.sort_by_confidence_score }
|
scope :sort_by_archival_date, -> { archived.sort_by_confidence_score }
|
||||||
scope :sort_by_recommendations, -> { order(cached_votes_up: :desc) }
|
scope :sort_by_recommendations, -> { order(cached_votes_up: :desc) }
|
||||||
|
|
||||||
scope :archived, -> { where("proposals.created_at <= ?", Setting.archived_proposals_date_limit) }
|
scope :archived, -> { where(created_at: ...Setting.archived_proposals_date_limit) }
|
||||||
scope :not_archived, -> { where("proposals.created_at > ?", Setting.archived_proposals_date_limit) }
|
scope :not_archived, -> { where(created_at: Setting.archived_proposals_date_limit..) }
|
||||||
scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago) }
|
scope :last_week, -> { where(created_at: 7.days.ago..) }
|
||||||
scope :retired, -> { where.not(retired_at: nil) }
|
scope :retired, -> { where.not(retired_at: nil) }
|
||||||
scope :not_retired, -> { where(retired_at: nil) }
|
scope :not_retired, -> { where(retired_at: nil) }
|
||||||
scope :successful, -> { where("cached_votes_up >= ?", Proposal.votes_needed_for_success) }
|
scope :successful, -> { where(cached_votes_up: Proposal.votes_needed_for_success..) }
|
||||||
scope :unsuccessful, -> { where("cached_votes_up < ?", Proposal.votes_needed_for_success) }
|
scope :unsuccessful, -> { where(cached_votes_up: ...Proposal.votes_needed_for_success) }
|
||||||
scope :public_for_api, -> { all }
|
scope :public_for_api, -> { all }
|
||||||
scope :selected, -> { where(selected: true) }
|
scope :selected, -> { where(selected: true) }
|
||||||
scope :not_selected, -> { where(selected: false) }
|
scope :not_selected, -> { where(selected: false) }
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class User < ApplicationRecord
|
|||||||
scope :moderators, -> { joins(:moderator) }
|
scope :moderators, -> { joins(:moderator) }
|
||||||
scope :organizations, -> { joins(:organization) }
|
scope :organizations, -> { joins(:organization) }
|
||||||
scope :sdg_managers, -> { joins(:sdg_manager) }
|
scope :sdg_managers, -> { joins(:sdg_manager) }
|
||||||
scope :officials, -> { where("official_level > 0") }
|
scope :officials, -> { where(official_level: 1..) }
|
||||||
scope :male, -> { where(gender: "male") }
|
scope :male, -> { where(gender: "male") }
|
||||||
scope :female, -> { where(gender: "female") }
|
scope :female, -> { where(gender: "female") }
|
||||||
scope :newsletter, -> { where(newsletter: true) }
|
scope :newsletter, -> { where(newsletter: true) }
|
||||||
@@ -233,13 +233,13 @@ class User < ApplicationRecord
|
|||||||
|
|
||||||
def full_restore
|
def full_restore
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
Debate.restore_all debates.where("hidden_at >= ?", hidden_at)
|
Debate.restore_all debates.where(hidden_at: hidden_at..)
|
||||||
Comment.restore_all comments.where("hidden_at >= ?", hidden_at)
|
Comment.restore_all comments.where(hidden_at: hidden_at..)
|
||||||
Legislation::Proposal.restore_all legislation_proposals.only_hidden.where("hidden_at >= ?", hidden_at)
|
Legislation::Proposal.restore_all legislation_proposals.only_hidden.where(hidden_at: hidden_at..)
|
||||||
Proposal.restore_all proposals.where("hidden_at >= ?", hidden_at)
|
Proposal.restore_all proposals.where(hidden_at: hidden_at..)
|
||||||
Budget::Investment.restore_all budget_investments.where("hidden_at >= ?", hidden_at)
|
Budget::Investment.restore_all budget_investments.where(hidden_at: hidden_at..)
|
||||||
ProposalNotification.restore_all(
|
ProposalNotification.restore_all(
|
||||||
ProposalNotification.only_hidden.where("hidden_at >= ?", hidden_at).where(author_id: id)
|
ProposalNotification.only_hidden.where(hidden_at: hidden_at..).where(author_id: id)
|
||||||
)
|
)
|
||||||
|
|
||||||
restore
|
restore
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ namespace :files do
|
|||||||
desc "Removes cached attachments which weren't deleted for some reason"
|
desc "Removes cached attachments which weren't deleted for some reason"
|
||||||
task remove_old_cached_attachments: :environment do
|
task remove_old_cached_attachments: :environment do
|
||||||
Tenant.run_on_each do
|
Tenant.run_on_each do
|
||||||
ActiveStorage::Blob.unattached
|
ActiveStorage::Blob.unattached.where(created_at: ..1.day.ago).find_each(&:purge_later)
|
||||||
.where("active_storage_blobs.created_at <= ?", 1.day.ago)
|
|
||||||
.find_each(&:purge_later)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user