Skip to content

Commit

Permalink
Fix rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWalkingLeek committed Jul 11, 2024
1 parent 08256db commit 1abe7d6
Show file tree
Hide file tree
Showing 32 changed files with 169 additions and 197 deletions.
4 changes: 3 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
inherit_from: ../hitobito/.rubocop.yml
inherit_from:
- ../hitobito/.rubocop.yml
- .rubocop_todo.yml

AllCops:
Exclude:
Expand Down
15 changes: 15 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit`
# on 2024-07-11 12:36:45 UTC using RuboCop version 1.64.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 3
# Configuration parameters: Include, AllowReads, AllowWrites.
# Include: app/**/*.rb, config/initializers/**/*.rb, lib/**/*.rb
Rails/EnvironmentVariableAccess:
Exclude:
- 'app/domain/data_extraction.rb'
- 'lib/hitobito_svse/wagon.rb'
8 changes: 4 additions & 4 deletions app/domain/data_extraction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ def initialize(filename, database)
@database = database
end

def query(table = nil, field_sql = '*', condition_sql = '')
raise ArgumentError, 'Table needs to be passed' if @query.nil? && table.nil?
def query(table = nil, field_sql = "*", condition_sql = "")
raise ArgumentError, "Table needs to be passed" if @query.nil? && table.nil?

@query = <<~SQL.split("\n").map(&:strip).join(' ').gsub(/\s+/, ' ')
@query = <<~SQL.split("\n").map(&:strip).join(" ").gsub(/\s+/, " ")
COPY (
SELECT #{field_sql}
FROM #{table}
Expand All @@ -42,7 +42,7 @@ def fetch(database = @database)
raise "No Query set, please use #{self.class.name}#query(table, fields, joins) to set one"
end

`psql -h #{ENV['PGHOSTNAME']} -U #{ENV['PGUSERNAME']} -c \"#{@query}\" #{database}`
`psql -h #{ENV["PGHOSTNAME"]} -U #{ENV["PGUSERNAME"]} -c \"#{@query}\" #{database}`
end

def write_file(data)
Expand Down
4 changes: 0 additions & 4 deletions app/domain/svse/export/tabular/people/people_full.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# encoding: utf-8

# Copyright (c) 2021, Schweizerischer Sportverband öffentlicher Verkehr. This file is part of
# hitobito_svse and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_svse.

module Svse::Export::Tabular::People
module PeopleFull

def person_attributes
super + [:created_at]
end

end
end
4 changes: 0 additions & 4 deletions app/domain/svse/export/tabular/people/person_row.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# encoding: utf-8

# Copyright (c) 2021, Schweizerischer Sportverband öffentlicher Verkehr. This file is part of
# hitobito_svse and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_svse.

module Svse::Export::Tabular::People
module PersonRow

def state
entry.state_label
end

end
end
1 change: 0 additions & 1 deletion app/helpers/svse/format_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# https://github.com/hitobito/hitobito_svse.

module Svse::FormatHelper

def format_person_created_at(person)
f(person.created_at.to_date)
end
Expand Down
5 changes: 2 additions & 3 deletions app/models/group/anlass.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# https://github.com/hitobito/hitobito_svse.

class Group::Anlass < ::Group

self.layer = true
self.event_types = [Event, Event::Course]

Expand All @@ -21,6 +20,6 @@ class Organisationsmitglied < ::Role
class Teilnehmer < ::Role; end

roles Kassier,
Organisationsmitglied,
Teilnehmer
Organisationsmitglied,
Teilnehmer
end
2 changes: 0 additions & 2 deletions app/models/group/ehemalige.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
# https://github.com/hitobito/hitobito_svse.

class Group::Ehemalige < ::Group

class Mitglied < ::Role; end

roles Mitglied

end
2 changes: 0 additions & 2 deletions app/models/group/ehrenmitglieder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
# https://github.com/hitobito/hitobito_svse.

class Group::Ehrenmitglieder < ::Group

### ROLES

class Mitglied < ::Role; end

roles Mitglied

end
2 changes: 0 additions & 2 deletions app/models/group/externe_kontakte.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
# https://github.com/hitobito/hitobito_svse.

class Group::ExterneKontakte < ::Group

### ROLES

class Kontakt < ::Role; end

roles Kontakt

end
2 changes: 0 additions & 2 deletions app/models/group/freimitglieder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
# https://github.com/hitobito/hitobito_svse.

class Group::Freimitglieder < ::Group

### ROLES

class Mitglied < ::Role; end

roles Mitglied

end
1 change: 0 additions & 1 deletion app/models/group/funktionaere.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# https://github.com/hitobito/hitobito_svse.

class Group::Funktionaere < ::Group

class Mitglied < ::Role
self.permissions = [:layer_full]
end
Expand Down
1 change: 0 additions & 1 deletion app/models/group/geschaeftsleitung.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# https://github.com/hitobito/hitobito_svse.

class Group::Geschaeftsleitung < ::Group

class Mitglied < ::Role
self.permissions = [:layer_and_below_read, :contact_data]
end
Expand Down
2 changes: 0 additions & 2 deletions app/models/group/passivmitglieder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
# https://github.com/hitobito/hitobito_svse.

class Group::Passivmitglieder < ::Group

class Mitglied < ::Role; end

roles Mitglied

end
2 changes: 0 additions & 2 deletions app/models/group/ressort_mitarbeitende.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
# https://github.com/hitobito/hitobito_svse.

class Group::RessortMitarbeitende < ::Group

### ROLES

class Mitglied < ::Role; end

roles Mitglied

end
30 changes: 14 additions & 16 deletions app/models/group/sektion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@
# https://github.com/hitobito/hitobito_svse.

class Group::Sektion < ::Group

self.layer = true
self.event_types = [Event, Event::Course]

children Group::Vorstand,
Group::Sportart,
Group::Anlass,
Group::Ehemalige,
Group::Freimitglieder,
Group::Passivmitglieder,
Group::Ehrenmitglieder,
Group::ExterneKontakte,
Group::Funktionaere
Group::Sportart,
Group::Anlass,
Group::Ehemalige,
Group::Freimitglieder,
Group::Passivmitglieder,
Group::Ehrenmitglieder,
Group::ExterneKontakte,
Group::Funktionaere

### ROLES

Expand All @@ -39,14 +38,13 @@ class Junior < ::Role
end

class Mitglied < ::Role; end
class Sponsor < ::Role; end

class Sponsor < ::Role; end

roles Mutationsfuehrer,
Kassier,
Mitglied,
LoginLernende,
Junior,
Sponsor

Kassier,
Mitglied,
LoginLernende,
Junior,
Sponsor
end
4 changes: 1 addition & 3 deletions app/models/group/sportart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# https://github.com/hitobito/hitobito_svse.

class Group::Sportart < ::Group

### ROLES

class OmbudsPerson < ::Role
Expand All @@ -16,6 +15,5 @@ class OmbudsPerson < ::Role
class Mitglied < ::Role; end

roles OmbudsPerson,
Mitglied

Mitglied
end
20 changes: 9 additions & 11 deletions app/models/group/svse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@
# https://github.com/hitobito/hitobito_svse.

class Group::Svse < ::Group

self.layer = true
self.event_types = [Event, Event::Course]

children Group::Geschaeftsleitung,
Group::RessortMitarbeitende,
Group::TechnischeKomission,
Group::Ehrenmitglieder,
Group::Ehemalige,
Group::ExterneKontakte,
Group::Passivmitglieder,
Group::Sektion
Group::RessortMitarbeitende,
Group::TechnischeKomission,
Group::Ehrenmitglieder,
Group::Ehemalige,
Group::ExterneKontakte,
Group::Passivmitglieder,
Group::Sektion

class Mutationsfuehrer < ::Role
self.permissions = [:layer_and_below_full]
Expand All @@ -30,7 +29,6 @@ class ItSupport < ::Role
class Sponsor < ::Role; end

roles Mutationsfuehrer,
ItSupport,
Sponsor

ItSupport,
Sponsor
end
2 changes: 0 additions & 2 deletions app/models/group/technische_komission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
# https://github.com/hitobito/hitobito_svse.

class Group::TechnischeKomission < ::Group

### ROLES

class Mitglied < ::Role
self.permissions = [:layer_and_below_read]
end

roles Mitglied

end
1 change: 0 additions & 1 deletion app/models/group/vorstand.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# https://github.com/hitobito/hitobito_svse.

class Group::Vorstand < ::Group

class Mitglied < ::Role
self.permissions = [:layer_and_below_full, :contact_data]
end
Expand Down
2 changes: 0 additions & 2 deletions app/models/svse/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_svse.


module Svse::Group
extend ActiveSupport::Concern

Expand All @@ -16,5 +15,4 @@ module Svse::Group

root_types Group::Svse
end

end
12 changes: 5 additions & 7 deletions app/models/svse/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,30 @@
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_svse.


module Svse::Person
extend ActiveSupport::Concern

included do
include I18nEnums

Person::PUBLIC_ATTRS << :title << :created_at << :died_at << :iban << :occupation <<
:recruited_at << :state
:recruited_at << :state

Person::INTERNAL_ATTRS << :recruited_by

Person::STATES = %w(active passive resigned deceased).freeze
Person::STATES = %w[active passive resigned deceased].freeze

before_save :set_deceased_state

belongs_to :recruited_by, class_name: 'Person'
belongs_to :recruited_by, class_name: "Person"

validates :recruited_at, :died_at,
timeliness: { type: :date, allow_blank: true, before: Date.new(9999, 12, 31) }
timeliness: {type: :date, allow_blank: true, before: Date.new(9999, 12, 31)}

i18n_enum :state, Person::STATES, scopes: true, queries: true

def set_deceased_state
self.state = 'deceased' if self.died_at.present?
self.state = "deceased" if died_at.present?
end
end

end
3 changes: 1 addition & 2 deletions app_root.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_svse.


# define the root directory of the main application
ENV['APP_ROOT'] ||= File.expand_path('../hitobito', __dir__)
ENV["APP_ROOT"] ||= File.expand_path("../hitobito", __dir__)
Loading

0 comments on commit 1abe7d6

Please sign in to comment.