Skip to content

Commit

Permalink
Fix rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWalkingLeek committed Jul 12, 2024
1 parent b670ca0 commit c89dacb
Show file tree
Hide file tree
Showing 529 changed files with 9,830 additions and 11,085 deletions.
30 changes: 5 additions & 25 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
inherit_from: ../hitobito/.rubocop.yml
inherit_from:
- ../hitobito/.rubocop.yml
- .rubocop_todo.yml

AllCops:
Exclude:
- Rakefile
- Gemfile
- db/**/*
- config/**/*
- bin/**/*
- tmp/**/*
- spec/**/*
- test/**/*
- vendor/**/*

Naming/MethodParameterName:
AllowedNames:
- lk
# defaults were (lets see what we really need):
# - at
# - by
# - db
# - id
# - in
# - io
# - ip
# - of
# - on
# - os
# - pp
# - to

Naming/VariableNumber:
AllowedPatterns:
- .*paragraph_74.*
22 changes: 22 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit`
# on 2024-07-12 11:30:59 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: 1
# Configuration parameters: Include, AllowReads, AllowWrites.
# Include: app/**/*.rb, config/initializers/**/*.rb, lib/**/*.rb
Rails/EnvironmentVariableAccess:
Exclude:
- 'lib/hitobito_insieme/wagon.rb'

# Offense count: 4
# Configuration parameters: Include.
# Include: app/helpers/**/*.rb
Rails/HelperInstanceVariable:
Exclude:
- 'app/helpers/dropdown/abo_addresses_export.rb'
- 'app/helpers/event/course_records_helper.rb'
7 changes: 3 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_cevi.

load File.expand_path('../app_root.rb', __FILE__)
load File.expand_path("../app_root.rb", __FILE__)

source 'https://rubygems.org'
source "https://rubygems.org"

# Declare your gem's dependencies in hitobito_insieme.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec

# Load application Gemfile for all application dependencies.
# rubocop:disable Security/Eval
eval File.read(File.expand_path('Gemfile', ENV['APP_ROOT']))
eval File.read(File.expand_path("Gemfile", ENV["APP_ROOT"])) # rubocop:disable Security/Eval

group :development, :test do
# Explicitly define the path for dependencies on other wagons.
Expand Down
17 changes: 8 additions & 9 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_cevi.


begin
require 'bundler/setup'
require "bundler/setup"
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
end

ENGINE_PATH = File.expand_path('..', __FILE__)
load File.expand_path('../app_root.rb', __FILE__)
ENGINE_PATH = File.expand_path("..", __FILE__)
load File.expand_path("../app_root.rb", __FILE__)

load 'wagons/wagon_tasks.rake'
load "wagons/wagon_tasks.rake"

load 'rspec/rails/tasks/rspec.rake'
load "rspec/rails/tasks/rspec.rake"

require 'ci/reporter/rake/rspec' unless Rails.env == 'production'
require "ci/reporter/rake/rspec" unless Rails.env.production?

HitobitoInsieme::Wagon.load_tasks

task 'test:prepare' => 'db:test:prepare'
task "test:prepare" => "db:test:prepare"
9 changes: 4 additions & 5 deletions app/abilities/event/course_record_ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# https://github.com/hitobito/hitobito_insieme.

class Event::CourseRecordAbility < AbilityDsl::Base

include AbilityDsl::Constraints::Event

on(Event::CourseRecord) do
Expand Down Expand Up @@ -36,10 +35,10 @@ def event
def controller_in_group?
event_group = event.groups.first

if event_group.class.const_defined?('Controlling')
user_context.user.roles.
select { |role| role.group_id == event_group.id }.
any? { |role| role.is_a?(event_group.class.const_get('Controlling')) }
if event_group.class.const_defined?(:Controlling)
user_context.user.roles
.select { |role| role.group_id == event_group.id }
.any? { |role| role.is_a?(event_group.class.const_get(:Controlling)) }
end
end
end
1 change: 0 additions & 1 deletion app/abilities/insieme/event_ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@ def participating
def in_regionalverein
event.groups.any? { |g| g.is_a?(Group::Regionalverein) }
end

end
96 changes: 47 additions & 49 deletions app/abilities/insieme/group_ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,55 +12,55 @@ module Insieme::GroupAbility
r.permissions.include?(:layer_and_below_full)
end

REPORTING_DACH_ROLES = DACH_MANAGER_ROLES + [Group::Dachverein::Controlling]
REPORTING_DACH_ROLES = DACH_MANAGER_ROLES + [Group::Dachverein::Controlling]

REPORTING_REGIO_ROLES = [Group::Regionalverein::Geschaeftsfuehrung,
Group::Regionalverein::Sekretariat,
Group::Regionalverein::Adressverwaltung,
Group::Regionalverein::Controlling,
Group::ExterneOrganisation::Geschaeftsfuehrung,
Group::ExterneOrganisation::Sekretariat,
Group::ExterneOrganisation::Adressverwaltung,
Group::ExterneOrganisation::Controlling].freeze
Group::Regionalverein::Sekretariat,
Group::Regionalverein::Adressverwaltung,
Group::Regionalverein::Controlling,
Group::ExterneOrganisation::Geschaeftsfuehrung,
Group::ExterneOrganisation::Sekretariat,
Group::ExterneOrganisation::Adressverwaltung,
Group::ExterneOrganisation::Controlling].freeze

included do # rubocop:disable Metrics/BlockLength
on(Group) do # rubocop:disable Metrics/BlockLength
permission(:any).
may(:read).
any_role_in_same_layer_or_layer_group_or_if_dachverein_manager

permission(:any).
may(:index_events, :'index_event/courses').
any_role_in_same_layer_or_if_dachverein_manager_or_if_regionalverein

permission(:any).may(:'index_event/aggregate_courses').in_same_group
permission(:group_full).may(:'export_event/aggregate_courses').in_same_group
permission(:group_and_below_full).
may(:'export_event/aggregate_courses').
in_same_group_or_below
permission(:layer_read).
may(:'index_event/aggregate_courses', :'export_event/aggregate_courses').
in_same_layer
permission(:layer_and_below_read).
may(:'index_event/aggregate_courses', :'export_event/aggregate_courses').
in_same_layer_or_below

permission(:any).may(:export_course_records).
if_dachverein_reporting_or_regionalverein_reporting_in_same_group

permission(:any).
may(:index_mailing_lists).
any_role_in_same_layer_or_if_dachverein_manager
permission(:any)
.may(:read)
.any_role_in_same_layer_or_layer_group_or_if_dachverein_manager

permission(:any)
.may(:index_events, :"index_event/courses")
.any_role_in_same_layer_or_if_dachverein_manager_or_if_regionalverein

permission(:any).may(:"index_event/aggregate_courses").in_same_group
permission(:group_full).may(:"export_event/aggregate_courses").in_same_group
permission(:group_and_below_full)
.may(:"export_event/aggregate_courses")
.in_same_group_or_below
permission(:layer_read)
.may(:"index_event/aggregate_courses", :"export_event/aggregate_courses")
.in_same_layer
permission(:layer_and_below_read)
.may(:"index_event/aggregate_courses", :"export_event/aggregate_courses")
.in_same_layer_or_below

permission(:any).may(:export_course_records)
.if_dachverein_reporting_or_regionalverein_reporting_in_same_group

permission(:any)
.may(:index_mailing_lists)
.any_role_in_same_layer_or_if_dachverein_manager

permission(:any).may(:deleted_subgroups).none
permission(:layer_full).may(:deleted_subgroups).in_same_layer
permission(:layer_and_below_full).may(:deleted_subgroups).in_same_layer_or_below

permission(:contact_data).may(:index_people).contact_data_in_same_layer

permission(:any).
may(:reporting).
if_dachverein_reporting_or_regionalverein_reporting_in_same_group
permission(:any)
.may(:reporting)
.if_dachverein_reporting_or_regionalverein_reporting_in_same_group

permission(:group_read).may(:statistics).in_same_group
permission(:group_and_below_read).may(:statistics).in_same_group
Expand All @@ -76,17 +76,16 @@ module Insieme::GroupAbility
general(:reporting).for_reporting_group
general(:statistics).for_dachverein
general(:controlling).for_dachverein

end
end

def if_permission_in_layer_and_manual_deletion_enabled
FeatureGate.enabled?('people.manual_deletion') && if_permission_in_layer
FeatureGate.enabled?("people.manual_deletion") && if_permission_in_layer
end

def if_dachverein_reporting_or_regionalverein_reporting_in_same_group
if_dachverein_reporting ||
if_regionalverein_reporting_in_same_group
if_regionalverein_reporting_in_same_group
end

def if_regionalverein_reporting_in_same_group
Expand All @@ -104,9 +103,9 @@ def if_dachverein_reporting

def any_role_in_same_layer_or_layer_group_or_if_dachverein_manager
any_role_in_same_layer ||
if_dachverein_manager ||
if_regionalverein_and_not_external_member ||
if_group_in_hierarchy
if_dachverein_manager ||
if_regionalverein_and_not_external_member ||
if_group_in_hierarchy
end

def any_role_in_same_layer_or_if_dachverein_manager
Expand All @@ -123,8 +122,8 @@ def any_role_in_same_layer

def contact_data_in_same_layer
group &&
user_context.layer_ids(user.groups_with_permission(:contact_data))
.include?(group.layer_group_id)
user_context.layer_ids(user.groups_with_permission(:contact_data))
.include?(group.layer_group_id)
end

def if_group_in_hierarchy
Expand All @@ -133,7 +132,7 @@ def if_group_in_hierarchy

def if_regionalverein_and_not_external_member
if_regionalverein &&
user_context.user.groups.any? { |g| g.layer_group.is_a?(Group::Regionalverein) }
user_context.user.groups.any? { |g| g.layer_group.is_a?(Group::Regionalverein) }
end

def if_regionalverein
Expand All @@ -150,9 +149,8 @@ def for_reporting_group

def any_role_in_same_group_except_external_and_addressverwaltung
user_context.user.roles.any? do |r|
r.group.id == group.id && r.class.name.demodulize != 'External' &&
r.class.name.demodulize != 'Adressverwaltung'
r.group.id == group.id && r.class.name.demodulize != "External" &&
r.class.name.demodulize != "Adressverwaltung"
end
end

end
1 change: 0 additions & 1 deletion app/abilities/insieme/mailing_list_ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ module Insieme::MailingListAbility
def any_role_in_same_layer
group && user_context.layer_ids(user_context.user.groups).include?(group.layer_group_id)
end

end
5 changes: 2 additions & 3 deletions app/abilities/insieme/person_ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ module Insieme::PersonAbility

def other_with_contact_data_in_same_layer
other_with_contact_data &&
contains_any?(user_context.layer_ids(user.groups_with_permission(:contact_data)),
subject.layer_group_ids)
contains_any?(user_context.layer_ids(user.groups_with_permission(:contact_data)),
subject.layer_group_ids)
end

end
6 changes: 3 additions & 3 deletions app/abilities/insieme/person_readables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ def contact_data_visible?
end

def contact_data_condition
['people.contact_data_visible = ? AND groups.layer_group_id IN (?)',
true,
contact_data_layer_ids]
["people.contact_data_visible = ? AND groups.layer_group_id IN (?)",
true,
contact_data_layer_ids]
end

def has_group_based_conditions?
Expand Down
1 change: 0 additions & 1 deletion app/abilities/insieme/various_ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ module Insieme::VariousAbility
permission(:admin).may(:show, :update).all
end
end

end
3 changes: 1 addition & 2 deletions app/controllers/abo_addresses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# https://github.com/hitobito/hitobito_insieme.

class AboAddressesController < ApplicationController

before_action :authorize

def index
Expand All @@ -20,7 +19,7 @@ def csv
end

def people
AboAddresses::Query.new(params[:country] == 'ch', params[:language]).people
AboAddresses::Query.new(params[:country] == "ch", params[:language]).people
end

def group
Expand Down
15 changes: 6 additions & 9 deletions app/controllers/capital_substrate_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,31 @@
# https://github.com/hitobito/hitobito_insieme.

class CapitalSubstrateController < ReportingBaseController

include Featureperioden::Views
include Featureperioden::Domain

helper_method :report

def edit; end
def edit
end

private

def report
@report ||= begin
fp_class('TimeRecord::Report::CapitalSubstrate').new(
fp_class('TimeRecord::Table').new(group, year)
)
end
@report ||= fp_class("TimeRecord::Report::CapitalSubstrate").new(
fp_class("TimeRecord::Table").new(group, year)
)
end

def entry
@entry ||= CapitalSubstrate.where(group_id: group.id, year: year).first_or_initialize
end

def permitted_params
params.require(:capital_substrate).permit(CapitalSubstrate.column_names - %w(id year group_id))
params.require(:capital_substrate).permit(CapitalSubstrate.column_names - %w[id year group_id])
end

def show_path
capital_substrate_group_path(group, year)
end

end
Loading

0 comments on commit c89dacb

Please sign in to comment.