Skip to content

Commit

Permalink
Lint whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
k-stewart committed Feb 16, 2018
1 parent 5615278 commit 120e379
Show file tree
Hide file tree
Showing 49 changed files with 236 additions and 205 deletions.
25 changes: 25 additions & 0 deletions .rubocop.yml
Expand Up @@ -11,6 +11,8 @@ AllCops:
- 'bin/**/*'
- 'vendor/**/*'

### Override rubcop-github ###

Style/FrozenStringLiteralComment:
# We aren't upgrading to Ruby 3.0, so this is just noise
Enabled: false
Expand Down Expand Up @@ -43,3 +45,26 @@ Lint/Debugger:
Style/BlockComments:
Exclude:
- 'spec/**/*'

Layout/SpaceInsideHashLiteralBraces:
Enabled: true

Layout/SpaceInsideBlockBraces:
Enabled: true

Layout/SpaceAroundEqualsInParameterDefault:
Enabled: true

Layout/ExtraSpacing:
Enabled: true

Layout/MultilineHashBraceLayout:
Enabled: true

Layout/SpaceAroundOperators:
Enabled: true

Security/JSONLoad:
Enabled: true
Exclude:
- 'spec/**/*'
4 changes: 2 additions & 2 deletions Gemfile
Expand Up @@ -51,10 +51,10 @@ gem "nokogiri" # Required for premailer-rails
gem "premailer-rails" # Inline styles for emails

# Optimization
gem "sprockets-image_compressor" # Optimizes png/jpg
gem "sprockets-image_compressor" # Optimizes png/jpg

# Analytics
gem "ahoy_matey" # Analytics
gem "ahoy_matey" # Analytics
gem "chartkick"
gem "groupdate"

Expand Down
12 changes: 6 additions & 6 deletions app/controllers/admin/action_pages_controller.rb
Expand Up @@ -17,10 +17,10 @@ def index
def update_featured_pages
FeaturedActionPage.destroy_all
featuredPages = Array.new
featuredPages << {action_page_id: featured_page_params[:fp4], weight: 4}
featuredPages << {action_page_id: featured_page_params[:fp3], weight: 3}
featuredPages << {action_page_id: featured_page_params[:fp2], weight: 2}
featuredPages << {action_page_id: featured_page_params[:fp1], weight: 1}
featuredPages << { action_page_id: featured_page_params[:fp4], weight: 4 }
featuredPages << { action_page_id: featured_page_params[:fp3], weight: 3 }
featuredPages << { action_page_id: featured_page_params[:fp2], weight: 2 }
featuredPages << { action_page_id: featured_page_params[:fp1], weight: 1 }
FeaturedActionPage.create(featuredPages)
#render :json => {success: true}, :status => 200
redirect_to({ action: "index" }, notice: "Featured pages updated")
Expand Down Expand Up @@ -70,7 +70,7 @@ def update

add_twitter_targets

redirect_to({ action: "edit", anchor: params[:anchor]}, notice: "Action Page was successfully updated.")
redirect_to({ action: "edit", anchor: params[:anchor] }, notice: "Action Page was successfully updated.")
end

def destroy
Expand Down Expand Up @@ -212,7 +212,7 @@ def purge_cache
uri = URI.parse("https://api.fastly.com/purge/" + page)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.path, {"Content-Type" => "application/json"})
request = Net::HTTP::Post.new(uri.path, { "Content-Type" => "application/json" })
response = http.request(request)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/s3_uploads_controller.rb
Expand Up @@ -11,7 +11,7 @@ def index
source_files = source_files.order(created_at: :desc)

respond_to do |format|
format.html{ render partial: "table", locals: { source_files: source_files } }
format.html { render partial: "table", locals: { source_files: source_files } }
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/exceptions_controller.rb
Expand Up @@ -9,7 +9,7 @@ def show
respond_to do |format|
format.html { render :show, status: @status_code, layout: !request.xhr? }
format.xml { render xml: details, root: "error", status: @status_code }
format.json { render json: {error: details}, status: @status_code }
format.json { render json: { error: details }, status: @status_code }
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/petition_controller.rb
Expand Up @@ -5,7 +5,7 @@ class PetitionController < ApplicationController
def recent_signatures
signatories = @petition.recent_signatures(5)
signatures_total = @petition.signatures.count
render json: {signatories: signatories, signatures_total: signatures_total}
render json: { signatories: signatories, signatures_total: signatures_total }
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/registrations_controller.rb
Expand Up @@ -47,7 +47,7 @@ def after_update_path_for(resource)

def set_create_notice
if resource.errors.empty?
cookies[:sweetAlert] = JSON.dump({title: "Thanks!", text: "A message with a confirmation link has been sent to your email address. Please open the link to activate your account."})
cookies[:sweetAlert] = JSON.dump({ title: "Thanks!", text: "A message with a confirmation link has been sent to your email address. Please open the link to activate your account." })
flash[:notice] = nil
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/sns_controller.rb
Expand Up @@ -12,7 +12,7 @@ def bounce
recipients.each do |recipient|
Bounce.create(email: recipient["emailAddress"].downcase)
end
render json: {success: true}
render json: { success: true }
end

def complaint
Expand All @@ -24,7 +24,7 @@ def complaint
feedback_type: message["complaint"]["complaintFeedbackType"],
body: message)
end
render json: {success: true}
render json: { success: true }
end

private
Expand Down
18 changes: 9 additions & 9 deletions app/controllers/tools_controller.rb
Expand Up @@ -66,7 +66,7 @@ def petition
)

@source = "action center petition :: " + @action_page.title
@user.subscribe!(opt_in=true, source=@source)
@user.subscribe!(opt_in = true, source = @source)
end

if params[:update_user_data]
Expand All @@ -78,7 +78,7 @@ def petition
action_page: @action_page

respond_to do |format|
format.json { render json: {success: true}, status: 200 }
format.json { render json: { success: true }, status: 200 }
format.html do
begin
url = URI.parse(request.referrer)
Expand All @@ -90,15 +90,15 @@ def petition
end
end
else
render json: {errors: @signature.errors.to_json}, status: 200
render json: { errors: @signature.errors.to_json }, status: 200
end
end

def tweet
ahoy.track "Action",
{ type: "action", actionType: "tweet", actionPageId: params[:action_id] },
action_page: @action_page
render json: {success: true}, status: 200
render json: { success: true }, status: 200
end

def message_congress
Expand All @@ -118,11 +118,11 @@ def message_congress
)

@source = "action center congress message :: " + @action_page.title
@user.subscribe!(opt_in=true, source=@source)
@user.subscribe!(opt_in = true, source = @source)
end

@name = email_params[:first_name] # for deliver_thanks_message
render json: {success: true}, status: 200
render json: { success: true }, status: 200
end

def email
Expand All @@ -149,9 +149,9 @@ def reps
if @reps.present?
update_user_data(params.slice(:street_address, :zipcode)) if params[:update_user_data] == "true"

render json: {content: render_to_string(partial: "action_page/reps")}, status: 200
render json: { content: render_to_string(partial: "action_page/reps") }, status: 200
else
render json: {error: "No representatives found"}, status: 200
render json: { error: "No representatives found" }, status: 200
end
end

Expand All @@ -164,7 +164,7 @@ def reps_raw
if @reps.present?
render json: @reps, status: 200
else
render json: {error: "No representatives found"}, status: 200
render json: { error: "No representatives found" }, status: 200
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Expand Up @@ -5,7 +5,7 @@ def show
send_cache_disablement_headers

@actionPages = ActionPage.order("id desc")
@actions_taken = current_user.events.actions.map {|i| i["properties"]["actionPageId"].to_i}
@actions_taken = current_user.events.actions.map { |i| i["properties"]["actionPageId"].to_i }
end

def update
Expand Down
116 changes: 58 additions & 58 deletions app/helpers/application_helper.rb
Expand Up @@ -13,8 +13,8 @@ def twitter_handle

def markdown(blogtext)
blogtext = substitute_keywords(blogtext)
renderOptions = {hard_wrap: true, filter_html: false}
markdownOptions = {autolink: true, no_intra_emphasis: true, fenced_code_blocks: true}
renderOptions = { hard_wrap: true, filter_html: false }
markdownOptions = { autolink: true, no_intra_emphasis: true, fenced_code_blocks: true }
markdown = Redcarpet::Markdown.new(MarkdownRenderer.new(renderOptions), markdownOptions)
markdown.render(blogtext).html_safe # rubocop:disable Rails/OutputSafety
end
Expand Down Expand Up @@ -293,62 +293,62 @@ def country_codes

def us_states_hash
{
"Alabama"=>"AL",
"Alaska"=>"AK",
"American Samoa"=>"AS",
"Arizona"=>"AZ",
"Arkansas"=>"AR",
"California"=>"CA",
"Colorado"=>"CO",
"Connecticut"=>"CT",
"Delaware"=>"DE",
"District of Columbia"=>"DC",
"Florida"=>"FL",
"Georgia"=>"GA",
"Guam"=>"GU",
"Hawaii"=>"HI",
"Idaho"=>"ID",
"Illinois"=>"IL",
"Indiana"=>"IN",
"Iowa"=>"IA",
"Kansas"=>"KS",
"Kentucky"=>"KY",
"Louisiana"=>"LA",
"Maine"=>"ME",
"Maryland"=>"MD",
"Massachusetts"=>"MA",
"Michigan"=>"MI",
"Minnesota"=>"MN",
"Mississippi"=>"MS",
"Missouri"=>"MO",
"Montana"=>"MT",
"Nebraska"=>"NE",
"Nevada"=>"NV",
"New Hampshire"=>"NH",
"New Jersey"=>"NJ",
"New Mexico"=>"NM",
"New York"=>"NY",
"North Carolina"=>"NC",
"North Dakota"=>"ND",
"Northern Mariana Islands"=>"MP",
"Ohio"=>"OH",
"Oklahoma"=>"OK",
"Oregon"=>"OR",
"Pennsylvania"=>"PA",
"Puerto Rico"=>"PR",
"Rhode Island"=>"RI",
"South Carolina"=>"SC",
"South Dakota"=>"SD",
"Tennessee"=>"TN",
"Texas"=>"TX",
"Utah"=>"UT",
"Vermont"=>"VT",
"Virgin Islands"=>"VI",
"Virginia"=>"VA",
"Washington"=>"WA",
"West Virginia"=>"WV",
"Wisconsin"=>"WI",
"Wyoming"=>"WY"
"Alabama" => "AL",
"Alaska" => "AK",
"American Samoa" => "AS",
"Arizona" => "AZ",
"Arkansas" => "AR",
"California" => "CA",
"Colorado" => "CO",
"Connecticut" => "CT",
"Delaware" => "DE",
"District of Columbia" => "DC",
"Florida" => "FL",
"Georgia" => "GA",
"Guam" => "GU",
"Hawaii" => "HI",
"Idaho" => "ID",
"Illinois" => "IL",
"Indiana" => "IN",
"Iowa" => "IA",
"Kansas" => "KS",
"Kentucky" => "KY",
"Louisiana" => "LA",
"Maine" => "ME",
"Maryland" => "MD",
"Massachusetts" => "MA",
"Michigan" => "MI",
"Minnesota" => "MN",
"Mississippi" => "MS",
"Missouri" => "MO",
"Montana" => "MT",
"Nebraska" => "NE",
"Nevada" => "NV",
"New Hampshire" => "NH",
"New Jersey" => "NJ",
"New Mexico" => "NM",
"New York" => "NY",
"North Carolina" => "NC",
"North Dakota" => "ND",
"Northern Mariana Islands" => "MP",
"Ohio" => "OH",
"Oklahoma" => "OK",
"Oregon" => "OR",
"Pennsylvania" => "PA",
"Puerto Rico" => "PR",
"Rhode Island" => "RI",
"South Carolina" => "SC",
"South Dakota" => "SD",
"Tennessee" => "TN",
"Texas" => "TX",
"Utah" => "UT",
"Vermont" => "VT",
"Virgin Islands" => "VI",
"Virginia" => "VA",
"Washington" => "WA",
"West Virginia" => "WV",
"Wisconsin" => "WI",
"Wyoming" => "WY"
}
end

Expand Down
2 changes: 1 addition & 1 deletion app/helpers/devise_helper.rb
Expand Up @@ -38,7 +38,7 @@ def devise_error_messages!
end

def devise_error_messages?
@hasErrorMessages ? true: false
@hasErrorMessages ? true : false
end

def locked_account?
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/petition_helper.rb
@@ -1,7 +1,7 @@
module PetitionHelper
def legislator_title(legislator)
prefix = legislator.chamber == "senate" ? "Senator" : "Representative"
[prefix, @legislator.last_name].join(" ")
[prefix, @legislator.last_name].join(" ")
end

def signature_location(signature)
Expand Down
2 changes: 1 addition & 1 deletion app/models/action_page.rb
Expand Up @@ -32,7 +32,7 @@ class ActionPage < ActiveRecord::Base
#validates_length_of :og_title, maximum: 65
after_save :no_drafts_on_homepage

scope :categorized, ->(category){ joins(:category).where(categories: { title: category }) }
scope :categorized, ->(category) { joins(:category).where(categories: { title: category }) }

def should_generate_new_friendly_id?
# create slugs with FriendlyId and respect our custom slugs
Expand Down
2 changes: 1 addition & 1 deletion app/models/congress_member.rb
@@ -1,7 +1,7 @@
class CongressMember < ActiveRecord::Base
validates_uniqueness_of :bioguide_id

scope :current, ->{ where("? <= term_end", Time.now) }
scope :current, -> { where("? <= term_end", Time.now) }

scope :filter, ->(f) do
if f.present?
Expand Down
6 changes: 3 additions & 3 deletions app/models/markdown_renderer.rb
Expand Up @@ -2,12 +2,12 @@ class MarkdownRenderer < Redcarpet::Render::HTML
# Assume 'code' here is actually just more markdown
# that wants to be rendered and wrapped in a .letter class
def block_code(code, language)
renderOptions = {hard_wrap: true, filter_html: false}
markdownOptions = {autolink: true, no_intra_emphasis: true}
renderOptions = { hard_wrap: true, filter_html: false }
markdownOptions = { autolink: true, no_intra_emphasis: true }
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(renderOptions), markdownOptions)

if language == "letter"
ApplicationController.new.render_to_string partial: "action_page/letter", locals: { description: code}, layout: false
ApplicationController.new.render_to_string partial: "action_page/letter", locals: { description: code }, layout: false
else
"<div class='#{language}'>#{markdown.render(code)}</div>"
end
Expand Down

0 comments on commit 120e379

Please sign in to comment.