Skip to content

Commit

Permalink
fix: change rubocop rules and fix migrations modified by rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
AyakorK committed Jan 18, 2024
1 parent 5933649 commit f89cfa7
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 20 deletions.
5 changes: 4 additions & 1 deletion .rubocop_rails.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,13 @@ Rails/Validation:
Include:
- app/models/**/*.rb

Rails/CompactBlank:
Enabled: false

Rails/BulkChangeTable:
Exclude:
- db/**/*

RSpec/MultipleMemoizedHelpers:
Exclude:
- spec/**/**
- spec/**/**
18 changes: 9 additions & 9 deletions .rubocop_ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ AllCops:
- "vendor/**/*"
- "node_modules/**/*"
- "db/schema.rb"
- "db/migrate/*.rb"
- "bin/*"
# Default formatter will be used if no -f/--format option is given.
DefaultFormatter: progress
Expand Down Expand Up @@ -67,12 +68,7 @@ AllCops:
# If a value is specified for TargetRubyVersion then it is used.
# Else if .ruby-version exists and it contains an MRI version it is used.
# Otherwise we fallback to the oldest officially supported Ruby version (2.0).
TargetRubyVersion: 2.7

RSpec:
Patterns:
- "(?:^|/)spec/"
- "(?:^|/)test/"
TargetRubyVersion: 3.0

Lint/SafeNavigationChain:
Exclude:
Expand Down Expand Up @@ -287,6 +283,9 @@ Style/HashEachMethods:
Style/HashLikeCase:
MinBranchesCount: 5

Style/OpenStructUse:
Enabled: false

# Indentation of `when`.
Layout/CaseIndentation:
EnforcedStyle: case
Expand Down Expand Up @@ -1272,10 +1271,11 @@ RSpec/NamedSubject:
Enabled: false

RSpec/RepeatedExampleGroupDescription:
Enabled: false
Enabled: true

RSpec/RepeatedExampleGroupBody:
Enabled: false
Enabled: true

RSpec/VerifiedDoubles:
Enabled: false

Expand Down Expand Up @@ -1764,4 +1764,4 @@ Faker/DeprecatedArguments:
- random_words_to_add
questions:
- number
- supplemental
- supplemental
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source "https://rubygems.org"

DECIDIM_VERSION = "0.27"
DECIDIM_BRANCH = "release/#{DECIDIM_VERSION}-stable"
DECIDIM_BRANCH = "release/#{DECIDIM_VERSION}-stable".freeze

ruby RUBY_VERSION

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class AddCancelDataToSortition < ActiveRecord::Migration[5.1]
def change
add_column :decidim_module_sortitions_sortitions, :cancel_reason, :jsonb
add_column :decidim_module_sortitions_sortitions, :cancelled_on, :datetime
add_column :decidim_module_sortitions_sortitions, :cancelled_by_user_id, :integer
add_index :decidim_module_sortitions_sortitions, :cancelled_by_user_id
add_column :decidim_module_sortitions_sortitions, :cancelled_by_user_id, :integer, index: true
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ class IndexForeignKeysInDecidimActionLogs < ActiveRecord::Migration[5.2]
def change
add_index :decidim_action_logs, :decidim_area_id
add_index :decidim_action_logs, :decidim_scope_id
add_index :decidim_action_logs, :version_id
add_index :decidim_action_logs, :version_id unless index_exists?(:decidim_action_logs, :version_id)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

class IndexForeignKeysInDecidimCommentsComments < ActiveRecord::Migration[5.2]
def change
add_index :decidim_comments_comments, :decidim_user_group_id
add_index :decidim_comments_comments, :decidim_user_group_id unless index_exists?(:decidim_comments_comments, :decidim_user_group_id)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

class IndexForeignKeysInDecidimAccountabilityResults < ActiveRecord::Migration[5.2]
def change
add_index :decidim_accountability_results, :external_id
add_index :decidim_accountability_results, :external_id unless index_exists?(:decidim_accountability_results, :external_id)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

class AddIndexToDecidimUsersNotificationsSendingFrequency < ActiveRecord::Migration[6.0]
def change
add_index :decidim_users, :notifications_sending_frequency
add_index :decidim_users, :notifications_sending_frequency unless index_exists?(:decidim_users, :notifications_sending_frequency)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

class AddStateIdToDecidimProposalsProposals < ActiveRecord::Migration[6.0]
def up
add_column :decidim_proposals_proposals, :decidim_proposals_proposal_state_id, :integer
add_index :decidim_proposals_proposals, :decidim_proposals_proposal_state_id
add_column :decidim_proposals_proposals, :decidim_proposals_proposal_state_id, :integer, index: true

add_foreign_key :decidim_proposals_proposals, :decidim_proposals_proposal_states, column: :decidim_proposals_proposal_state_id
end
Expand Down
31 changes: 31 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
t.float "weight", default: 1.0
t.string "external_id"
t.integer "comments_count", default: 0, null: false
t.index ["comments_count"], name: "index_decidim_accountability_results_on_comments_count"
t.index ["decidim_accountability_status_id"], name: "decidim_accountability_results_on_status_id"
t.index ["decidim_component_id"], name: "index_decidim_accountability_results_on_decidim_component_id"
t.index ["decidim_scope_id"], name: "index_decidim_accountability_results_on_decidim_scope_id"
Expand Down Expand Up @@ -207,6 +208,7 @@
t.index ["decidim_organization_id", "slug"], name: "index_unique_assembly_slug_and_organization", unique: true
t.index ["decidim_organization_id"], name: "index_decidim_assemblies_on_decidim_organization_id"
t.index ["decidim_scope_id"], name: "index_decidim_assemblies_on_decidim_scope_id"
t.index ["follows_count"], name: "index_decidim_assemblies_on_follows_count"
t.index ["parent_id"], name: "decidim_assemblies_assemblies_on_parent_id"
end

Expand Down Expand Up @@ -275,6 +277,7 @@
t.integer "weight", default: 0, null: false
t.integer "attachment_collection_id"
t.index ["attached_to_id", "attached_to_type"], name: "index_decidim_attachments_on_attached_to"
t.index ["attachment_collection_id"], name: "index_decidim_attachments_attachment_collection_id"
t.index ["attachment_collection_id"], name: "index_decidim_attachments_on_attachment_collection_id"
end

Expand Down Expand Up @@ -352,9 +355,12 @@
t.integer "endorsements_count", default: 0, null: false
t.integer "comments_count", default: 0, null: false
t.integer "follows_count", default: 0, null: false
t.index ["comments_count"], name: "index_decidim_blogs_posts_on_comments_count"
t.index ["decidim_author_id", "decidim_author_type"], name: "index_decidim_blogs_posts_on_decidim_author"
t.index ["decidim_author_id"], name: "index_decidim_blogs_posts_on_decidim_author_id"
t.index ["decidim_component_id"], name: "index_decidim_blogs_posts_on_decidim_component_id"
t.index ["decidim_user_group_id"], name: "index_decidim_blogs_posts_on_decidim_user_group_id"
t.index ["follows_count"], name: "index_decidim_blogs_posts_on_follows_count"
end

create_table "decidim_budgets_budgets", id: :serial, force: :cascade do |t|
Expand Down Expand Up @@ -403,8 +409,11 @@
t.date "selected_at"
t.integer "comments_count", default: 0, null: false
t.integer "follows_count", default: 0, null: false
t.index ["comments_count"], name: "index_decidim_budgets_projects_on_comments_count"
t.index ["decidim_budgets_budget_id"], name: "index_decidim_budgets_projects_on_decidim_budgets_budget_id"
t.index ["decidim_scope_id"], name: "index_decidim_budgets_projects_on_decidim_scope_id"
t.index ["follows_count"], name: "index_decidim_budgets_projects_on_follows_count"
t.index ["selected_at"], name: "index_decidim_budgets_projects_on_selected_at"
end

create_table "decidim_calendar_external_events", force: :cascade do |t|
Expand Down Expand Up @@ -483,6 +492,7 @@
t.string "decidim_participatory_space_type"
t.integer "decidim_participatory_space_id"
t.datetime "deleted_at"
t.index ["comments_count"], name: "index_decidim_comments_comments_on_comments_count"
t.index ["created_at"], name: "index_decidim_comments_comments_on_created_at"
t.index ["decidim_author_id", "decidim_author_type"], name: "index_decidim_comments_comments_on_decidim_author"
t.index ["decidim_author_id"], name: "decidim_comments_comment_author"
Expand Down Expand Up @@ -575,11 +585,13 @@
t.integer "follows_count", default: 0, null: false
t.boolean "comments_enabled", default: true
t.index ["closed_at"], name: "index_decidim_debates_debates_on_closed_at"
t.index ["comments_count"], name: "index_decidim_debates_debates_on_comments_count"
t.index ["decidim_author_id", "decidim_author_type"], name: "index_decidim_debates_debates_on_decidim_author"
t.index ["decidim_component_id"], name: "index_decidim_debates_debates_on_decidim_component_id"
t.index ["decidim_scope_id"], name: "index_decidim_debates_debates_on_decidim_scope_id"
t.index ["decidim_user_group_id"], name: "index_decidim_debates_debates_on_decidim_user_group_id"
t.index ["endorsements_count"], name: "idx_decidim_debates_debates_on_endorsemnts_count"
t.index ["follows_count"], name: "index_decidim_debates_debates_on_follows_count"
end

create_table "decidim_editor_images", force: :cascade do |t|
Expand Down Expand Up @@ -851,10 +863,14 @@
t.string "state"
t.integer "iframe_access_level", default: 0
t.integer "iframe_embed_type", default: 0
t.index ["closed_at"], name: "index_decidim_meetings_meetings_on_closed_at"
t.index ["decidim_author_id", "decidim_author_type"], name: "index_decidim_meetings_meetings_on_author"
t.index ["decidim_author_id"], name: "index_decidim_meetings_meetings_on_decidim_author_id"
t.index ["decidim_component_id"], name: "index_decidim_meetings_meetings_on_decidim_component_id"
t.index ["decidim_scope_id"], name: "index_decidim_meetings_meetings_on_decidim_scope_id"
t.index ["follows_count"], name: "index_decidim_meetings_meetings_on_follows_count"
t.index ["published_at"], name: "index_decidim_meetings_meetings_on_published_at"
t.index ["state"], name: "index_decidim_meetings_meetings_on_state"
end

create_table "decidim_meetings_polls", force: :cascade do |t|
Expand Down Expand Up @@ -883,6 +899,7 @@
t.integer "status", default: 0
t.index ["decidim_questionnaire_id"], name: "index_decidim_meetings_questions_on_decidim_questionnaire_id"
t.index ["position"], name: "index_decidim_meetings_questions_on_position"
t.index ["status"], name: "index_decidim_meetings_questions_on_status"
end

create_table "decidim_meetings_registrations", force: :cascade do |t|
Expand All @@ -894,6 +911,7 @@
t.datetime "validated_at"
t.bigint "decidim_user_group_id"
t.boolean "public_participation", default: false
t.index ["code"], name: "index_decidim_meetings_registrations_on_code"
t.index ["decidim_meeting_id"], name: "index_decidim_meetings_registrations_on_decidim_meeting_id"
t.index ["decidim_user_group_id"], name: "index_decidim_meetings_registrations_on_decidim_user_group_id"
t.index ["decidim_user_id", "decidim_meeting_id"], name: "decidim_meetings_registrations_user_meeting_unique", unique: true
Expand Down Expand Up @@ -1086,6 +1104,7 @@
t.boolean "enable_participatory_space_filters", default: true
t.index ["host"], name: "index_decidim_organizations_on_host", unique: true
t.index ["name"], name: "index_decidim_organizations_on_name", unique: true
t.index ["secondary_hosts"], name: "index_decidim_organizations_on_secondary_hosts"
end

create_table "decidim_pages_pages", id: :serial, force: :cascade do |t|
Expand Down Expand Up @@ -1113,6 +1132,7 @@
t.jsonb "participatory_structure"
t.boolean "promoted", default: false
t.index ["decidim_organization_id"], name: "decidim_participatory_process_group_organization"
t.index ["promoted"], name: "index_decidim_participatory_process_groups_on_promoted"
end

create_table "decidim_participatory_process_steps", id: :serial, force: :cascade do |t|
Expand Down Expand Up @@ -1197,6 +1217,9 @@
t.index ["decidim_participatory_process_type_id"], name: "index_decidim_processes_on_decidim_process_type_id"
t.index ["decidim_scope_id"], name: "idx_process_on_scope_id"
t.index ["decidim_scope_type_id"], name: "index_decidim_participatory_processes_on_decidim_scope_type_id"
t.index ["follows_count"], name: "index_decidim_participatory_processes_on_follows_count"
t.index ["promoted"], name: "index_decidim_participatory_processes_on_promoted"
t.index ["published_at"], name: "index_decidim_participatory_processes_on_published_at"
end

create_table "decidim_participatory_space_links", id: :serial, force: :cascade do |t|
Expand Down Expand Up @@ -1250,8 +1273,10 @@
t.integer "comments_count", default: 0, null: false
t.integer "follows_count", default: 0, null: false
t.index ["body"], name: "decidim_proposals_collaborative_draft_body_search"
t.index ["comments_count"], name: "index_decidim_proposals_collaborative_drafts_on_comments_count"
t.index ["decidim_component_id"], name: "decidim_proposals_collaborative_drafts_on_decidim_component_id"
t.index ["decidim_scope_id"], name: "decidim_proposals_collaborative_drafts_on_decidim_scope_id"
t.index ["follows_count"], name: "index_decidim_proposals_collaborative_drafts_on_follows_count"
t.index ["state"], name: "decidim_proposals_collaborative_drafts_on_state"
t.index ["title"], name: "decidim_proposals_collaborative_drafts_title_search"
t.index ["updated_at"], name: "decidim_proposals_collaborative_drafts_on_updated_at"
Expand Down Expand Up @@ -1338,10 +1363,14 @@
t.integer "decidim_proposals_proposal_state_id"
t.index "md5((body)::text)", name: "decidim_proposals_proposal_body_search"
t.index "md5((title)::text)", name: "decidim_proposals_proposal_title_search"
t.index ["answered_at"], name: "index_decidim_proposals_proposals_on_answered_at"
t.index ["comments_count"], name: "index_decidim_proposals_proposals_on_comments_count"
t.index ["created_at"], name: "index_decidim_proposals_proposals_on_created_at"
t.index ["decidim_component_id"], name: "index_decidim_proposals_proposals_on_decidim_component_id"
t.index ["decidim_scope_id"], name: "index_decidim_proposals_proposals_on_decidim_scope_id"
t.index ["follows_count"], name: "index_decidim_proposals_proposals_on_follows_count"
t.index ["proposal_votes_count"], name: "index_decidim_proposals_proposals_on_proposal_votes_count"
t.index ["published_at"], name: "index_decidim_proposals_proposals_on_published_at"
t.index ["state"], name: "index_decidim_proposals_proposals_on_state"
end

Expand Down Expand Up @@ -1515,6 +1544,7 @@
t.string "decidim_author_type", null: false
t.integer "comments_count", default: 0, null: false
t.index ["cancelled_by_user_id"], name: "index_decidim_sortitions_sortitions_on_cancelled_by_user_id"
t.index ["comments_count"], name: "index_decidim_sortitions_sortitions_on_comments_count"
t.index ["decidim_author_id", "decidim_author_type"], name: "index_decidim_sortitions_sortitions_on_decidim_author"
t.index ["decidim_author_id"], name: "index_decidim_sortitions_sortitions_on_decidim_author_id"
t.index ["decidim_component_id"], name: "index_sortitions__on_feature"
Expand Down Expand Up @@ -1706,6 +1736,7 @@
t.index ["confirmation_token"], name: "index_decidim_users_on_confirmation_token", unique: true
t.index ["decidim_organization_id"], name: "index_decidim_users_on_decidim_organization_id"
t.index ["email", "decidim_organization_id"], name: "index_decidim_users_on_email_and_decidim_organization_id", unique: true, where: "((deleted_at IS NULL) AND (managed = false) AND ((type)::text = 'Decidim::User'::text))"
t.index ["follows_count"], name: "index_decidim_users_on_follows_count"
t.index ["id", "type"], name: "index_decidim_users_on_id_and_type"
t.index ["invitation_token"], name: "index_decidim_users_on_invitation_token", unique: true
t.index ["invitations_count"], name: "index_decidim_users_on_invitations_count"
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Decidim::Dev.dummy_app_path = File.expand_path(Rails.root.to_s)
require "decidim/dev/test/base_spec_helper"

Dir.glob("./spec/support/**/*.rb").sort.each { |f| require f }
Dir.glob("./spec/support/**/*.rb").each { |f| require f }

RSpec.configure do |config|
config.formatter = ENV.fetch("RSPEC_FORMAT", "progress").to_sym
Expand Down

0 comments on commit f89cfa7

Please sign in to comment.