Skip to content

Commit

Permalink
Rubocop: Spacing around operators etc
Browse files Browse the repository at this point in the history
  • Loading branch information
CloCkWeRX committed Jan 10, 2017
1 parent 6d141dd commit a7c65a3
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 98 deletions.
69 changes: 0 additions & 69 deletions .rubocop_todo.yml
Expand Up @@ -666,75 +666,6 @@ Style/SingleLineBlockParams:
Exclude:
- 'spec/support/macros.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleInsidePipes, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceAroundBlockParameters:
Exclude:
- 'spec/controllers/tasks_controller_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/SpaceAroundKeyword:
Exclude:
- 'lib/fat_free_crm/core_ext/string.rb'

# Offense count: 15
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Style/SpaceAroundOperators:
Exclude:
- 'app/controllers/entities/contacts_controller.rb'
- 'app/helpers/versions_helper.rb'
- 'app/models/fields/field.rb'
- 'config/environments/test.rb'
- 'spec/models/entities/opportunity_spec.rb'
- 'spec/models/fields/custom_field_pair_spec.rb'
- 'spec/views/tasks/index.haml_spec.rb'
- 'spec/views/tasks/update.js.haml_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceBeforeBlockBraces:
Exclude:
- 'app/controllers/application_controller.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
# SupportedStyles: space, no_space
Style/SpaceInsideBlockBraces:
Exclude:
- 'app/controllers/application_controller.rb'

# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
# SupportedStyles: space, no_space, compact
Style/SpaceInsideHashLiteralBraces:
Exclude:
- 'app/helpers/application_helper.rb'
- 'spec/support/auth_macros.rb'

# Offense count: 2
# Cop supports --auto-correct.
Style/SpaceInsidePercentLiteralDelimiters:
Exclude:
- 'config/initializers/assets.rb'

# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceInsideStringInterpolation:
Exclude:
- 'app/helpers/application_helper.rb'
- 'app/helpers/tasks_helper.rb'
- 'lib/gravatar_image_tag.rb'

# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowSafeAssignment.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -45,7 +45,7 @@ def auto_complete
respond_to do |format|
format.any(:js, :html) { render partial: 'auto_complete' }
format.json do
render json: @auto_complete.each_with_object({}){|a, h|
render json: @auto_complete.each_with_object({}) { |a, h|
h[a.id] = a.respond_to?(:full_name) ? h(a.full_name) : h(a.name); h
}
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/entities/contacts_controller.rb
Expand Up @@ -153,7 +153,7 @@ def get_accounts

def set_options
super
@naming = (current_user.pref[:contacts_naming] || Contact.first_name_position) unless params[:cancel].true?
@naming = (current_user.pref[:contacts_naming] || Contact.first_name_position) unless params[:cancel].true?
end

#----------------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions app/helpers/application_helper.rb
Expand Up @@ -36,7 +36,7 @@ def show_flash(options = { sticky: false })
#----------------------------------------------------------------------------
def subtitle(id, hidden = true, text = id.to_s.split("_").last.capitalize)
content_tag("div",
link_to("<small>#{ hidden ? '&#9658;' : '&#9660;' }</small> #{sanitize text}".html_safe,
link_to("<small>#{hidden ? '&#9658;' : '&#9660;'}</small> #{sanitize text}".html_safe,
url_for(controller: :home, action: :toggle, id: id),
remote: true,
onclick: "crm.flip_subtitle(this)"
Expand Down Expand Up @@ -244,7 +244,7 @@ def refresh_sidebar(action = nil, shake = nil)
#----------------------------------------------------------------------------
def refresh_sidebar_for(view, action = nil, shake = nil)
text = ""
text << "$('#sidebar').html('#{ j render(partial: 'layouts/sidebar', locals: { view: view, action: action }) }');"
text << "$('#sidebar').html('#{j render(partial: 'layouts/sidebar', locals: { view: view, action: action })}');"
text << "$('##{j shake.to_s}').effect('shake', { duration:200, distance: 3 });" if shake
text.html_safe
end
Expand Down Expand Up @@ -439,7 +439,7 @@ def col(title, value = nil, last = false, email = false, &_block)
def section_title(id, hidden = true, text = nil, info_text = nil)
text = id.to_s.split("_").last.capitalize if text.nil?
content_tag("div", class: "subtitle show_attributes") do
content = link_to("<small>#{ hidden ? '&#9658;' : '&#9660;' }</small> #{sanitize text}".html_safe,
content = link_to("<small>#{hidden ? '&#9658;' : '&#9660;'}</small> #{sanitize text}".html_safe,
url_for(controller: :home, action: :toggle, id: id),
remote: true,
onclick: "crm.flip_subtitle(this)"
Expand Down Expand Up @@ -520,7 +520,7 @@ def get_icon(name)
# options = { renderer: {...} , params: {...}
def paginate(options = {})
collection = options.delete(:collection)
options = { params: { action: 'index'}}.merge(options) if params['action'] == 'filter'
options = { params: { action: 'index' } }.merge(options) if params['action'] == 'filter'
options = { renderer: RemoteLinkPaginationHelper::LinkRenderer }.merge(options)
will_paginate(collection, options)
end
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/tasks_helper.rb
Expand Up @@ -94,21 +94,21 @@ def hide_task_and_possibly_bucket(task, bucket)
def replace_content(task, bucket = nil)
partial = (task.assigned_to && task.assigned_to != current_user.id) ? "assigned" : "pending"
html = render(partial: "tasks/#{partial}", collection: [task], locals: { bucket: bucket })
text = "$('##{dom_id(task)}').html('#{ j html }');\n".html_safe
text = "$('##{dom_id(task)}').html('#{j html}');\n".html_safe
end

#----------------------------------------------------------------------------
def insert_content(task, bucket, view)
text = "$('#list_#{bucket}').show();\n"
html = render(partial: view, collection: [task], locals: { bucket: bucket })
text << "$('##{h bucket.to_s}').prepend('#{ j html }');\n"
text << "$('##{h bucket.to_s}').prepend('#{j html}');\n"
text << "$('##{dom_id(task)}').effect('highlight', { duration:1500 });\n"
text.html_safe
end

#----------------------------------------------------------------------------
def tasks_flash(message)
text = "$('#flash').html('#{ sanitize(message) }');\n"
text = "$('#flash').html('#{sanitize(message)}');\n"
text << "crm.flash('notice', true)\n"
text.html_safe
end
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/versions_helper.rb
Expand Up @@ -23,7 +23,7 @@ def parse_version(attr_name, change)
first = link_to(h(account.name), account_path(account))
end
if second.present? && (account = Account.find_by_id(second))
second = link_to(h(account.name), account_path(account))
second = link_to(h(account.name), account_path(account))
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/fields/field.rb
Expand Up @@ -46,7 +46,7 @@ class Field < ActiveRecord::Base
'url' => { klass: 'CustomField', type: 'string' },
'tel' => { klass: 'CustomField', type: 'string' },
'select' => { klass: 'CustomField', type: 'string' },
'radio_buttons' => { klass: 'CustomField', type: 'string' },
'radio_buttons' => { klass: 'CustomField', type: 'string' },
'check_boxes' => { klass: 'CustomField', type: 'text' },
'boolean' => { klass: 'CustomField', type: 'boolean' },
'date' => { klass: 'CustomField', type: 'date' },
Expand Down
2 changes: 1 addition & 1 deletion config/environments/test.rb
Expand Up @@ -28,7 +28,7 @@
config.action_dispatch.show_exceptions = false

# Disable request forgery protection in test environment
config.action_controller.allow_forgery_protection = false
config.action_controller.allow_forgery_protection = false

# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/assets.rb
Expand Up @@ -8,7 +8,7 @@

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
Rails.application.config.assets.precompile += %w( print.css chosen-sprite.png jquery-ui/* jquery_ui_datepicker/*.js )
Rails.application.config.assets.precompile += %w(print.css chosen-sprite.png jquery-ui/* jquery_ui_datepicker/*.js)

# Don't initialize Rails environment
Rails.application.config.assets.initialize_on_precompile = false
2 changes: 1 addition & 1 deletion lib/fat_free_crm/core_ext/string.rb
Expand Up @@ -34,7 +34,7 @@ def false?
# A query with 4 words will generate 6 permutations
def name_permutations
parts = split(" ")
(parts.size - 1).times.map do|i|
(parts.size - 1).times.map do |i|
# ["A", "B", "C", "D"] => [["A B C", "D"], ["A B", "C D"], ["A", "B C D"]]
[parts[(0..i)].join(" "), parts[(i + 1)..-1].join(" ")]
end.each_with_object([]) do |perm, arr|
Expand Down
2 changes: 1 addition & 1 deletion lib/gravatar_image_tag.rb
Expand Up @@ -46,7 +46,7 @@ def self.gravatar_url_base(secure = false)
end

def self.gravatar_id(email, filetype = nil)
"#{ Digest::MD5.hexdigest(email) }#{ ".#{filetype}" unless filetype.nil? }" unless email.nil?
"#{Digest::MD5.hexdigest(email)}#{".#{filetype}" unless filetype.nil?}" unless email.nil?
end

def self.url_params(gravatar_params)
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/tasks_controller_spec.rb
Expand Up @@ -14,7 +14,7 @@ def update_sidebar
def produce_tasks(user, view)
settings = (view != "completed" ? Setting.task_bucket : Setting.task_completed)

settings.each_with_object({}) do | due, hash |
settings.each_with_object({}) do |due, hash|
hash[due] ||= []
if Date.tomorrow == Date.today.end_of_week && due == :due_tomorrow
due = :due_this_week
Expand Down
2 changes: 1 addition & 1 deletion spec/models/entities/opportunity_spec.rb
Expand Up @@ -35,7 +35,7 @@
end

it "should be possible to create opportunity with the same name" do
first = FactoryGirl.create(:opportunity, name: "Hello", user: current_user)
first = FactoryGirl.create(:opportunity, name: "Hello", user: current_user)
expect { FactoryGirl.create(:opportunity, name: "Hello", user: current_user) }.to_not raise_error
end

Expand Down
4 changes: 2 additions & 2 deletions spec/models/fields/custom_field_pair_spec.rb
Expand Up @@ -18,7 +18,7 @@ class CustomFieldFooPair
@field = { 'as' => 'foopair', 'field_group_id' => 1, 'label' => 'Event' }
@pair1 = { 'name' => 'pair1' }
@pair2 = { 'name' => 'pair2' }
@params = { 'field' => @field, 'pair' => { '0' => @pair1, '1' => @pair2 } }
@params = { 'field' => @field, 'pair' => { '0' => @pair1, '1' => @pair2 } }
end

it "should create the pair" do
Expand All @@ -38,7 +38,7 @@ class CustomFieldFooPair
@field = { 'as' => 'foopair', 'field_group_id' => 1, 'label' => 'Event' }
@pair1 = { 'name' => 'pair1' }
@pair2 = { 'name' => 'pair2' }
@params = { 'id' => '3', 'field' => @field, 'pair' => { '0' => @pair1, '1' => @pair2 } }
@params = { 'id' => '3', 'field' => @field, 'pair' => { '0' => @pair1, '1' => @pair2 } }
end

it "should update the pair" do
Expand Down
4 changes: 2 additions & 2 deletions spec/support/auth_macros.rb
Expand Up @@ -17,7 +17,7 @@ def activate_authlogic
#----------------------------------------------------------------------------
def login(user_stubs = {}, session_stubs = {})
User.current_user = @current_user = FactoryGirl.create(:user, user_stubs)
@current_user_session = double(Authentication, {record: current_user}.merge(session_stubs))
@current_user_session = double(Authentication, { record: current_user }.merge(session_stubs))
allow(Authentication).to receive(:find).and_return(@current_user_session)
#set_timezone
end
Expand All @@ -26,7 +26,7 @@ def login(user_stubs = {}, session_stubs = {})
#----------------------------------------------------------------------------
def login_and_assign(user_stubs = {}, session_stubs = {})
User.current_user = @current_user = FactoryGirl.build_stubbed(:user, user_stubs)
@current_user_session = double(Authentication, {record: current_user}.merge(session_stubs))
@current_user_session = double(Authentication, { record: current_user }.merge(session_stubs))
allow(Authentication).to receive(:find).and_return(@current_user_session)
#set_timezone
assigns[:current_user] = current_user
Expand Down
2 changes: 1 addition & 1 deletion spec/views/tasks/index.haml_spec.rb
Expand Up @@ -16,7 +16,7 @@
before do
user = FactoryGirl.build_stubbed(:user)
account = FactoryGirl.build_stubbed(:account)
@due = FactoryGirl.build_stubbed(:task, asset: account, bucket: "due_asap", assignee: user)
@due = FactoryGirl.build_stubbed(:task, asset: account, bucket: "due_asap", assignee: user)
@completed = FactoryGirl.build_stubbed(:task, asset: account, bucket: "completed_today", assignee: user, completed_at: 1.hour.ago, completor: user)
end

Expand Down
14 changes: 7 additions & 7 deletions spec/views/tasks/update.js.haml_spec.rb
Expand Up @@ -15,7 +15,7 @@
describe "Changing due date" do
before do
assign(:task_before_update, FactoryGirl.build_stubbed(:task, bucket: "due_asap"))
assign(:task, @task = FactoryGirl.build_stubbed(:task, bucket: "due_tomorrow"))
assign(:task, @task = FactoryGirl.build_stubbed(:task, bucket: "due_tomorrow"))
assign(:view, "pending")
assign(:task_total, stub_task_total("pending"))
end
Expand Down Expand Up @@ -64,7 +64,7 @@
it "pending task to somebody from Tasks tab: should remove the task and show flash message (assigned)" do
assignee = FactoryGirl.build_stubbed(:user)
assign(:task_before_update, FactoryGirl.build_stubbed(:task, assignee: nil))
assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: assignee))
assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: assignee))
assign(:view, "pending")
controller.request.env["HTTP_REFERER"] = "http://localhost/tasks"

Expand All @@ -78,7 +78,7 @@
it "assigned tasks to me from Tasks tab: should remove the task and show flash message (pending)" do
assignee = FactoryGirl.build_stubbed(:user)
assign(:task_before_update, FactoryGirl.build_stubbed(:task, assignee: assignee))
assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: nil))
assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: nil))
assign(:view, "assigned")
controller.request.env["HTTP_REFERER"] = "http://localhost/tasks?view=assigned"

Expand All @@ -91,7 +91,7 @@

it "assigned tasks to somebody else from Tasks tab: should re-render task partial" do
assign(:task_before_update, FactoryGirl.build_stubbed(:task, assignee: FactoryGirl.build_stubbed(:user)))
assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: FactoryGirl.build_stubbed(:user)))
assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: FactoryGirl.build_stubbed(:user)))
assign(:view, "assigned")
controller.request.env["HTTP_REFERER"] = "http://localhost/tasks?view=assigned"

Expand All @@ -101,7 +101,7 @@

it "from Tasks tab: should update tasks sidebar" do
assign(:task_before_update, FactoryGirl.build_stubbed(:task, assignee: nil))
assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: FactoryGirl.build_stubbed(:user)))
assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: FactoryGirl.build_stubbed(:user)))
assign(:view, "assigned")
controller.request.env["HTTP_REFERER"] = "http://localhost/tasks?view=assigned"
render
Expand All @@ -114,15 +114,15 @@

it "from asset page: should should re-render task partial" do
assign(:task_before_update, FactoryGirl.build_stubbed(:task, assignee: nil))
assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: FactoryGirl.build_stubbed(:user)))
assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: FactoryGirl.build_stubbed(:user)))
render

expect(rendered).to include("$('#task_#{@task.id}').html('<li class=\\'highlight task\\' id=\\'task_#{@task.id}\\'")
end

it "from asset page: should update recently viewed items" do
assign(:task_before_update, FactoryGirl.build_stubbed(:task, assignee: nil))
assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: FactoryGirl.build_stubbed(:user)))
assign(:task, @task = FactoryGirl.build_stubbed(:task, assignee: FactoryGirl.build_stubbed(:user)))
render

expect(rendered).to have_text("Recent Items")
Expand Down

0 comments on commit a7c65a3

Please sign in to comment.