Skip to content

Commit

Permalink
Enable Style/IndentationWidth cop
Browse files Browse the repository at this point in the history
The offenses were fixed manually
  • Loading branch information
AEtherC0r3 authored and differentreality committed Jul 14, 2017
1 parent e3b51df commit 9c58397
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 81 deletions.
11 changes: 0 additions & 11 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -469,17 +469,6 @@ Style/IndentationConsistency:
- 'app/models/event.rb'
- 'spec/controllers/subscriptions_controller_spec.rb'

# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: Width, IgnoredPatterns.
Style/IndentationWidth:
Exclude:
- 'app/helpers/format_helper.rb'
- 'app/serializers/conference_serializer.rb'
- 'db/migrate/20140701123203_add_events_per_week_to_conference.rb'
- 'lib/tasks/demo_data_for_development.rake'
- 'spec/models/ability_spec.rb'

# Offense count: 4
# Cop supports --auto-correct.
Style/LeadingCommentSpace:
Expand Down
9 changes: 4 additions & 5 deletions app/helpers/format_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,12 @@ def class_for_todo(bool)
end
end

# rubocop:disable Lint/EndAlignment
def word_pluralize(count, singular, plural = nil)
word = if (count == 1 || count =~ /^1(\.0+)?$/)
singular
else
plural || singular.pluralize
end
singular
else
plural || singular.pluralize
end

"#{word}"
end
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/conference_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def revision

def date_range
if defined? date_string(object.start_date, object.end_date)
date_string(object.start_date, object.end_date).try(:split, ',').try(:first)
date_string(object.start_date, object.end_date).try(:split, ',').try(:first)
end
end
end
72 changes: 36 additions & 36 deletions db/migrate/20140701123203_add_events_per_week_to_conference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,50 +22,50 @@ def up
if event
conference = TempConference.find_by_id(event.conference_id)
if conference
week = event_version.created_at.end_of_week
week = event_version.created_at.end_of_week

no_events = {
new: 0,
withdrawn: 0,
unconfirmed: 0,
confirmed: 0,
canceled: 0,
rejected: 0,
}

if !conference.events_per_week
conference.events_per_week = {
week => no_events
no_events = {
new: 0,
withdrawn: 0,
unconfirmed: 0,
confirmed: 0,
canceled: 0,
rejected: 0,
}
elsif !conference.events_per_week[week]
conference.events_per_week[week] = no_events
end

if event_version.object_changes &&
event_version.event == 'create'
if !conference.events_per_week
conference.events_per_week = {
week => no_events
}
elsif !conference.events_per_week[week]
conference.events_per_week[week] = no_events
end

# Increment the new state
conference.events_per_week[week][:new] += 1
elsif event_version.object_changes &&
event_version.object_changes[:state]
if event_version.object_changes &&
event_version.event == 'create'

prev_state = event_version.object_changes[:state][0].to_sym
next_state = event_version.object_changes[:state][1].to_sym
# Increment the new state
conference.events_per_week[week][:new] += 1
elsif event_version.object_changes &&
event_version.object_changes[:state]

# Backward compatibility: deprecated state :review now :new
if prev_state == :review
prev_state = :new
elsif next_state == :review
next_state = :new
end
prev_state = event_version.object_changes[:state][0].to_sym
next_state = event_version.object_changes[:state][1].to_sym

# Increment the next state
conference.events_per_week[week][next_state] += 1
# Backward compatibility: deprecated state :review now :new
if prev_state == :review
prev_state = :new
elsif next_state == :review
next_state = :new
end

# Decrement the previous state
conference.events_per_week[week][prev_state] -= 1
end
conference.save
# Increment the next state
conference.events_per_week[week][next_state] += 1

# Decrement the previous state
conference.events_per_week[week][prev_state] -= 1
end
conference.save
end
end
end
Expand Down
50 changes: 25 additions & 25 deletions lib/tasks/demo_data_for_development.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,37 @@ namespace :data do
include FactoryGirl::Syntax::Methods

def generate_program conference
program = conference.program
user1 = create(:user)
user2 = create(:user)
program = conference.program
user1 = create(:user)
user2 = create(:user)

conference_rooms = conference.venue.rooms
conference_rooms = conference.venue.rooms

selected_schedule = create(:schedule, program: program)
demo_schedule = create(:schedule, program: program)
program.update_attributes!(selected_schedule: selected_schedule)
selected_schedule = create(:schedule, program: program)
demo_schedule = create(:schedule, program: program)
program.update_attributes!(selected_schedule: selected_schedule)

create(:event, program: program, title: 'Demo Event', abstract: 'This is a demo event instance whose state not defined.')
create(:event, program: program, title: 'Demo Rejected Event', state: 'rejected', abstract: 'This is demo event instance in a rejected state.')
create(:event, program: program, title: 'Demo Unconfirmed Event', state: 'unconfirmed', abstract: 'This is a demo event instance in unconfirmed state.')
create(:event, program: program, title: 'Demo Confirmed Unscheduled Event', state: 'confirmed', abstract: 'This is a demo event instance in a confirmed state.')
create(:event, program: program, title: 'Demo Event', abstract: 'This is a demo event instance whose state not defined.')
create(:event, program: program, title: 'Demo Rejected Event', state: 'rejected', abstract: 'This is demo event instance in a rejected state.')
create(:event, program: program, title: 'Demo Unconfirmed Event', state: 'unconfirmed', abstract: 'This is a demo event instance in unconfirmed state.')
create(:event, program: program, title: 'Demo Confirmed Unscheduled Event', state: 'confirmed', abstract: 'This is a demo event instance in a confirmed state.')

first_scheduled_event = create(:event, program: program, title: 'first_scheduled_event', state: 'confirmed', abstract: 'This is a demo scheduled event instance.')
second_scheduled_event = create(:event, program: program, title: 'second_scheduled_event', state: 'confirmed', abstract: 'This is a demo scheduled event instance.')
multiple_speaker_event = create(:event, program: program, title: 'multiple_speaker_event', state: 'confirmed', abstract: 'This is a demo scheduled event instance having multiple speakers.')
first_scheduled_event = create(:event, program: program, title: 'first_scheduled_event', state: 'confirmed', abstract: 'This is a demo scheduled event instance.')
second_scheduled_event = create(:event, program: program, title: 'second_scheduled_event', state: 'confirmed', abstract: 'This is a demo scheduled event instance.')
multiple_speaker_event = create(:event, program: program, title: 'multiple_speaker_event', state: 'confirmed', abstract: 'This is a demo scheduled event instance having multiple speakers.')

create(:event_user, event: multiple_speaker_event, user: user1, event_role: 'speaker')
create(:event_user, event: multiple_speaker_event, user: user2, event_role: 'speaker')
create(:event_user, event: multiple_speaker_event, user: user1, event_role: 'speaker')
create(:event_user, event: multiple_speaker_event, user: user2, event_role: 'speaker')

create(:event_schedule, event: first_scheduled_event, schedule: selected_schedule, start_time: conference.start_date + conference.start_hour.hours, room: conference_rooms.first)
create(:event_schedule, event: second_scheduled_event, schedule: selected_schedule, start_time: conference.start_date + conference.start_hour.hours + 15.minutes, room: conference_rooms.second)
create(:event_schedule, event: multiple_speaker_event, schedule: selected_schedule, start_time: conference.start_date + conference.start_hour.hours + 30.minutes, room: conference_rooms.third)
create(:event_schedule, event: first_scheduled_event, schedule: demo_schedule, start_time: conference.start_date + conference.start_hour.hours + 15.minutes, room: conference_rooms.third)
create(:event_schedule, event: second_scheduled_event, schedule: demo_schedule, start_time: conference.start_date + conference.start_hour.hours + 30.minutes, room: conference_rooms.third)
create(:event_schedule, event: multiple_speaker_event, schedule: demo_schedule, start_time: conference.start_date + conference.start_hour.hours, room: conference_rooms.first)
create(:event_schedule, event: first_scheduled_event, schedule: selected_schedule, start_time: conference.start_date + conference.start_hour.hours, room: conference_rooms.first)
create(:event_schedule, event: second_scheduled_event, schedule: selected_schedule, start_time: conference.start_date + conference.start_hour.hours + 15.minutes, room: conference_rooms.second)
create(:event_schedule, event: multiple_speaker_event, schedule: selected_schedule, start_time: conference.start_date + conference.start_hour.hours + 30.minutes, room: conference_rooms.third)
create(:event_schedule, event: first_scheduled_event, schedule: demo_schedule, start_time: conference.start_date + conference.start_hour.hours + 15.minutes, room: conference_rooms.third)
create(:event_schedule, event: second_scheduled_event, schedule: demo_schedule, start_time: conference.start_date + conference.start_hour.hours + 30.minutes, room: conference_rooms.third)
create(:event_schedule, event: multiple_speaker_event, schedule: demo_schedule, start_time: conference.start_date + conference.start_hour.hours, room: conference_rooms.first)

create(:registration, user: user1, conference: conference)
create(:registration, user: user2, conference: conference)
create(:registration, user: user1, conference: conference)
create(:registration, user: user2, conference: conference)
end

# This is a full conference demo instance that will happen in the future.
Expand Down Expand Up @@ -73,5 +73,5 @@ namespace :data do
# Registration for this conference has reached its limit.
conference = create(:full_conference, title: 'Zypper Docker Conference', short_title: 'zypper', registration_limit: 2, start_date: 3.days.from_now, end_date: 7.days.from_now, start_hour: 7, end_hour: 19, description: 'This is a full conference demo instance. Its registrations has reached the limit.')
generate_program conference
end
end
end
6 changes: 3 additions & 3 deletions spec/models/ability_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
it{ should_not be_able_to(:show, conference_not_public)}

it do
conference_public.program.schedule_public = true
conference_public.program.save
should be_able_to(:schedule, conference_public)
conference_public.program.schedule_public = true
conference_public.program.save
should be_able_to(:schedule, conference_public)
end
it{ should_not be_able_to(:schedule, conference_not_public)}

Expand Down

0 comments on commit 9c58397

Please sign in to comment.