Add and apply rules for multi-line hashes

For the HashAlignment rule, we're using the default `key` style (keys
are aligned and values aren't) instead of the `table` style (both keys
and values are aligned) because, even if we used both in the
application, we used the `key` style a lot more. Furthermore, the
`table` style looks strange in places where there are both very long and
very short keys and sometimes we weren't even consistent with the
`table` style, aligning some keys without aligning other keys.

Ideally we could align hashes to "either key or table", so developers
can decide whether keeping the symmetry of the code is worth it in a
case-per-case basis, but Rubocop doesn't allow this option.
This commit is contained in:
Javi Martín
2023-07-01 16:17:33 +02:00
parent 97aca0cf95
commit 8b13daad95
130 changed files with 676 additions and 592 deletions

View File

@@ -26,55 +26,55 @@ class User < ApplicationRecord
has_many :proposals, -> { with_hidden }, foreign_key: :author_id, inverse_of: :author
has_many :activities
has_many :budget_investments, -> { with_hidden },
class_name: "Budget::Investment",
class_name: "Budget::Investment",
foreign_key: :author_id,
inverse_of: :author
inverse_of: :author
has_many :comments, -> { with_hidden }, inverse_of: :user
has_many :failed_census_calls
has_many :notifications
has_many :direct_messages_sent,
class_name: "DirectMessage",
class_name: "DirectMessage",
foreign_key: :sender_id,
inverse_of: :sender
inverse_of: :sender
has_many :direct_messages_received,
class_name: "DirectMessage",
class_name: "DirectMessage",
foreign_key: :receiver_id,
inverse_of: :receiver
inverse_of: :receiver
has_many :legislation_answers, class_name: "Legislation::Answer", dependent: :destroy, inverse_of: :user
has_many :follows
has_many :legislation_annotations,
class_name: "Legislation::Annotation",
class_name: "Legislation::Annotation",
foreign_key: :author_id,
inverse_of: :author
inverse_of: :author
has_many :legislation_proposals,
class_name: "Legislation::Proposal",
class_name: "Legislation::Proposal",
foreign_key: :author_id,
inverse_of: :author
inverse_of: :author
has_many :legislation_questions,
class_name: "Legislation::Question",
class_name: "Legislation::Question",
foreign_key: :author_id,
inverse_of: :author
inverse_of: :author
has_many :polls, foreign_key: :author_id, inverse_of: :author
has_many :poll_answers,
class_name: "Poll::Answer",
class_name: "Poll::Answer",
foreign_key: :author_id,
inverse_of: :author
inverse_of: :author
has_many :poll_pair_answers,
class_name: "Poll::PairAnswer",
class_name: "Poll::PairAnswer",
foreign_key: :author_id,
inverse_of: :author
inverse_of: :author
has_many :poll_partial_results,
class_name: "Poll::PartialResult",
class_name: "Poll::PartialResult",
foreign_key: :author_id,
inverse_of: :author
inverse_of: :author
has_many :poll_questions,
class_name: "Poll::Question",
class_name: "Poll::Question",
foreign_key: :author_id,
inverse_of: :author
inverse_of: :author
has_many :poll_recounts,
class_name: "Poll::Recount",
class_name: "Poll::Recount",
foreign_key: :author_id,
inverse_of: :author
inverse_of: :author
has_many :related_contents, foreign_key: :author_id, inverse_of: :author, dependent: nil
has_many :topics, foreign_key: :author_id, inverse_of: :author
belongs_to :geozone
@@ -136,7 +136,7 @@ class User < ApplicationRecord
oauth_user = User.find_by(email: oauth_email) if oauth_email_confirmed
oauth_user || User.new(
username: auth.info.name || auth.uid,
username: auth.info.name || auth.uid,
email: oauth_email,
oauth_email: oauth_email,
password: Devise.friendly_token[0, 20],