Skip to content
This repository was archived by the owner on Mar 9, 2020. It is now read-only.

Commit 0cb32c4

Browse files
committed
Become rubocop clean
1 parent c100b36 commit 0cb32c4

13 files changed

+81
-33
lines changed

.rubocop.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
AllCops:
2+
RunRailsCops: true
3+
Include:
4+
- '**/Rakefile'
5+
- '**/config.ru'
6+
Exclude:
7+
- 'bin/**/*'
8+
- 'config/**/*'
9+
- 'db/**/*'
10+
- 'script/**/*'
11+
- 'spec/**/*'
12+
13+
Style/LineLength:
14+
Max: 100
15+
16+
# Hubris, one of the Three Great Virtues
17+
# http://c2.com/cgi/wiki?LazinessImpatienceHubris
18+
Rails/HasAndBelongsToMany:
19+
Enabled: false
20+
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
# Functionality for all controllers:
2+
# * forgery protection
3+
# * default not_authenticated action
14
class ApplicationController < ActionController::Base
25
# Prevent CSRF attacks by raising an exception.
36
# For APIs, you may want to use :null_session instead.
47
protect_from_forgery with: :exception
58

69
def not_authenticated
7-
redirect_to login_url, :alert => "First login to access this page."
10+
redirect_to login_url, alert: 'First login to access this page.'
811
end
912
end

app/controllers/people_controller.rb

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# The main controller for people
12
class PeopleController < ApplicationController
23
include DefaultResponses
34
include DefaultSearch
@@ -50,13 +51,21 @@ def destroy
5051
end
5152

5253
private
53-
# Use callbacks to share common setup or constraints between actions.
54-
def set_person
55-
@person = Person.find(params[:id])
56-
end
57-
58-
# Never trust parameters from the scary internet, only allow the white list through.
59-
def person_params
60-
params.require(:person).permit(:login, :email, :password, :password_confirmation, :first_name, :middle_name, :last_name, :ssn, :birthdate, :address_line_1, :address_line_2, :address_line_3, :telephone_mobile, :telephone_office, :telephone_private, :personnel_number, :first_work_day, :working_hours_total, :working_hours_per_day, :holidays, :holidays_left, :hours, :overtime_hours, :job_description, :internal_notes)
61-
end
54+
55+
# Use callbacks to share common setup or constraints between actions.
56+
def set_person
57+
@person = Person.find(params[:id])
58+
end
59+
60+
# Never trust parameters from the scary internet, only allow the white listed
61+
# through.
62+
def person_params
63+
params.require(:person).permit(
64+
:login, :email, :password, :password_confirmation, :first_name,
65+
:middle_name, :last_name, :ssn, :birthdate, :address_line_1,
66+
:address_line_2, :address_line_3, :telephone_mobile, :telephone_office,
67+
:telephone_private, :personnel_number, :first_work_day,
68+
:working_hours_total, :working_hours_per_day, :holidays, :holidays_left,
69+
:hours, :overtime_hours, :job_description, :internal_notes)
70+
end
6271
end

app/controllers/projects_controller.rb

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# The main controller for projects
12
class ProjectsController < ApplicationController
23
include DefaultResponses
34
include DefaultSearch
@@ -21,7 +22,11 @@ def auto_complete_people_search
2122
# GET /projects/1
2223
# GET /projects/1.json
2324
def show
24-
@searched_people = params.has_key?(:people_search) ? Person.search_for(params[:people_search], :order => params[:people_order]) : []
25+
if params.key?(:people_search)
26+
@searched_people = Person.search_for(params[:people_search], order: params[:people_order])
27+
else
28+
@searched_people = []
29+
end
2530
end
2631

2732
def add_person
@@ -59,13 +64,15 @@ def destroy
5964
end
6065

6166
private
62-
# Use callbacks to share common setup or constraints between actions.
63-
def set_project
64-
@project = Project.find(params[:id])
65-
end
6667

67-
# Never trust parameters from the scary internet, only allow the white list through.
68-
def project_params
69-
params.require(:project).permit(:name)
70-
end
68+
# Use callbacks to share common setup or constraints between actions.
69+
def set_project
70+
@project = Project.find(params[:id])
71+
end
72+
73+
# Never trust parameters from the scary internet, only allow the white listed
74+
# through.
75+
def project_params
76+
params.require(:project).permit(:name)
77+
end
7178
end
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1+
# Manage logged in users
12
class SessionsController < ApplicationController
2-
33
def create
44
user = login(params[:email], params[:password], params[:remember_me])
55
if user
6-
redirect_back_or_to root_url, :notice => "Logged in!"
6+
redirect_back_or_to root_url, notice: 'Logged in!'
77
else
8-
flash.now.alert = "Email or password was invalid"
8+
flash.now.alert = 'Email or password was invalid!'
99
render :new
1010
end
1111
end
1212

1313
def destroy
1414
logout
15-
redirect_to root_url, :notice => "Logged out!"
15+
redirect_to root_url, notice: 'Logged out!'
1616
end
17-
1817
end

app/controllers/welcome_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
# Homepage
12
class WelcomeController < ApplicationController
2-
#before_filter :require_login, :only => :index
3+
# No login required here
4+
# before_filter :require_login, :only => :index
35

46
def index
57
end

app/helpers/application_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
# Nothing to see here
12
module ApplicationHelper
23
end

app/helpers/people_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
# Nothing to see here
12
module PeopleHelper
23
end

app/helpers/projects_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
# Nothing to see here
12
module ProjectsHelper
23
end

app/helpers/sessions_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
# Nothing to see here
12
module SessionsHelper
23
end

0 commit comments

Comments
 (0)