Skip to content

Commit

Permalink
Fixes various spacing related rubocop offences
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroenj committed Dec 8, 2015
1 parent 15052a4 commit 03686da
Show file tree
Hide file tree
Showing 52 changed files with 75 additions and 137 deletions.
59 changes: 8 additions & 51 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2015-12-07 21:05:42 +0100 using RuboCop version 0.34.2.
# on 2015-12-07 21:19:03 +0100 using RuboCop version 0.34.2.
# 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
Expand Down Expand Up @@ -64,7 +64,7 @@ Metrics/ClassLength:
Metrics/CyclomaticComplexity:
Max: 9

# Offense count: 137
# Offense count: 131
# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
Max: 352
Expand Down Expand Up @@ -193,13 +193,12 @@ Style/EmptyLinesAroundAccessModifier:
- 'app/models/story.rb'
- 'app/tasks/fetch_feed.rb'

# Offense count: 4
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/EmptyLinesAroundBlockBody:
Exclude:
- 'app/utils/opml_parser.rb'
- 'db/schema.rb'
- 'spec/models/story_spec.rb'

# Offense count: 2
Expand Down Expand Up @@ -292,10 +291,10 @@ Style/Next:
- 'app/commands/feeds/import_from_opml.rb'
- 'app/repositories/story_repository.rb'

# Offense count: 11
# Offense count: 10
# Cop supports --auto-correct.
Style/NumericLiterals:
MinDigits: 15
MinDigits: 11

# Offense count: 4
# Cop supports --auto-correct.
Expand Down Expand Up @@ -358,49 +357,18 @@ Style/SingleLineMethods:
Exclude:
- 'app/utils/sample_story.rb'

# Offense count: 29
# Offense count: 6
# Cop supports --auto-correct.
Style/SingleSpaceBeforeFirstArg:
Exclude:
- 'app.rb'
- 'db/migrate/20130425222157_add_delayed_job.rb'
- 'db/schema.rb'

# Offense count: 6
# Cop supports --auto-correct.
Style/SpaceAfterComma:
Exclude:
- 'app/models/story.rb'
- 'app/utils/opml_parser.rb'
- 'spec/fever_api_spec.rb'
- 'spec/tasks/fetch_feed_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/SpaceAroundEqualsInParameterDefault:
Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: MultiSpaceAllowedForOperators.
Style/SpaceAroundOperators:
Exclude:
- 'app.rb'
- 'spec/factories/story_factory.rb'

# Offense count: 32
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/SpaceBeforeBlockBraces:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/SpaceBeforeComma:
Exclude:
- 'app/models/feed.rb'

# Offense count: 18
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
Expand All @@ -421,7 +389,7 @@ Style/SpaceInsideParens:
- 'spec/fever_api/read_feeds_spec.rb'
- 'spec/fever_api/read_items_spec.rb'

# Offense count: 960
# Offense count: 906
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/StringLiterals:
Expand Down Expand Up @@ -449,25 +417,14 @@ Style/SymbolProc:
- 'app/fever_api/sync_saved_item_ids.rb'
- 'app/fever_api/sync_unread_item_ids.rb'

# Offense count: 30
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/TrailingBlankLines:
Enabled: false

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
Style/TrailingComma:
Exclude:
- 'spec/fever_api/read_items_spec.rb'

# Offense count: 42
# Cop supports --auto-correct.
Style/TrailingWhitespace:
Enabled: false

# Offense count: 7
# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: WordRegex.
Style/WordArray:
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ task :work_jobs do
Delayed::Job.delete_all

3.times do
Delayed::Worker.new(:min_priority => ENV['MIN_PRIORITY'],
Delayed::Worker.new(:min_priority => ENV['MIN_PRIORITY'],
:max_priority => ENV['MAX_PRIORITY']).start
end
end
Expand Down Expand Up @@ -81,4 +81,4 @@ begin
task :default => [:speedy_tests]
rescue LoadError
# allow for bundle install --without development:test
end
end
4 changes: 2 additions & 2 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
require_relative "app/repositories/user_repository"

I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'config/locales', '*.yml').to_s]
I18n.config.enforce_available_locales=false
I18n.config.enforce_available_locales = false

class Stringer < Sinatra::Base
# need to exclude assets for sinatra assetpack, see https://github.com/swanson/stringer/issues/112
Expand Down Expand Up @@ -81,7 +81,7 @@ def t(*args)
"/css/styles.css"
]

js_compression :jsmin
js_compression :jsmin
css_compression :simple

prebuild true unless ENV['RACK_ENV'] == 'test'
Expand Down
2 changes: 1 addition & 1 deletion app/commands/feeds/add_new_feed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ def self.add(url, discoverer = FeedDiscovery.new, repo = Feed)
url: result.feed_url,
last_fetched: Time.now - ONE_DAY)
end
end
end
2 changes: 1 addition & 1 deletion app/commands/feeds/export_to_opml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ def to_xml

builder.to_xml
end
end
end
1 change: 0 additions & 1 deletion app/commands/stories/mark_all_as_read.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ def mark_as_read
@repo.fetch_by_ids(@story_ids).update_all(is_read: true)
end
end

1 change: 0 additions & 1 deletion app/commands/stories/mark_as_read.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ def mark_as_read
@repo.fetch(@story_id).update_attributes(is_read: true)
end
end

1 change: 0 additions & 1 deletion app/commands/stories/mark_as_starred.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ def mark_as_starred
@repo.fetch(@story_id).update_attributes(is_starred: true)
end
end

2 changes: 0 additions & 2 deletions app/commands/stories/mark_as_unread.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ def mark_as_unread
@repo.fetch(@story_id).update_attributes(is_read: false)
end
end


2 changes: 0 additions & 2 deletions app/commands/stories/mark_as_unstarred.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ def mark_as_unstarred
@repo.fetch(@story_id).update_attributes(is_starred: false)
end
end


1 change: 0 additions & 1 deletion app/commands/stories/mark_feed_as_read.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ def mark_feed_as_read
@repo.fetch_unread_for_feed_by_timestamp(@feed_id, @timestamp).update_all(is_read: true)
end
end

1 change: 0 additions & 1 deletion app/commands/stories/mark_group_as_read.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ def mark_group_as_read
end
end
end

2 changes: 1 addition & 1 deletion app/commands/users/complete_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ def self.complete(user)
user.save
user
end
end
end
6 changes: 3 additions & 3 deletions app/commands/users/create_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ def initialize(repository = User)

def create(password)
@repo.delete_all
@repo.create(password: password,
password_confirmation: password,
@repo.create(password: password,
password_confirmation: password,
setup_complete: false,
api_key: ApiKey.compute(password))
end
end
end
2 changes: 1 addition & 1 deletion app/commands/users/sign_in_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ def self.sign_in(submitted_password, repository = User)
nil
end
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/debug_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Stringer < Sinatra::Base
get "/debug" do
erb :"debug", locals: {
erb :"debug", locals: {
queued_jobs_count: Delayed::Job.count,
pending_migrations: MigrationStatus.new.pending_migrations
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/first_run_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ def no_password(params)
def password_mismatch?(params)
params[:password] != params[:password_confirmation]
end
end
end
4 changes: 2 additions & 2 deletions app/controllers/stories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Stringer < Sinatra::Base

put "/stories/:id" do
json_params = JSON.parse(request.body.read, symbolize_names: true)

story = StoryRepository.fetch(params[:id])
story.is_read = !!json_params[:is_read]
story.keep_unread = !!json_params[:keep_unread]
Expand All @@ -42,7 +42,7 @@ class Stringer < Sinatra::Base

post "/stories/mark_all_as_read" do
MarkAllAsRead.new(params[:story_ids]).mark_as_read

redirect to("/news")
end
end
2 changes: 1 addition & 1 deletion app/helpers/authentication_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ def current_user
UserRepository.fetch(session[:user_id])
end
end
end
end
2 changes: 1 addition & 1 deletion app/jobs/fetch_feed_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ def perform
feed = FeedRepository.fetch(feed_id)
FetchFeed.new(feed).fetch
end
end
end
2 changes: 1 addition & 1 deletion app/models/feed.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Feed < ActiveRecord::Base
has_many :stories, -> {order "published desc"} , dependent: :delete_all
has_many :stories, -> {order "published desc"}, dependent: :delete_all
belongs_to :group

validates_uniqueness_of :url
Expand Down
2 changes: 1 addition & 1 deletion app/models/migration_status.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class MigrationStatus
attr_reader :migrator

def initialize(migrator=ActiveRecord::Migrator)
def initialize(migrator = ActiveRecord::Migrator)
@migrator = migrator
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/story.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def headline
end

def lead
strip_html(self.body)[0,100]
strip_html(self.body)[0, 100]
end

def source
Expand Down
1 change: 0 additions & 1 deletion app/repositories/feed_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@ def self.valid_timestamp?(new_timestamp, current_timestamp)
(current_timestamp.nil? || new_timestamp > current_timestamp)
end
end

1 change: 0 additions & 1 deletion app/repositories/story_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,3 @@ def self.samples
]
end
end

4 changes: 2 additions & 2 deletions app/repositories/user_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class UserRepository
def self.fetch(id)
return nil unless id

User.find(id)
end

Expand All @@ -19,4 +19,4 @@ def self.save(user)
def self.first
User.first
end
end
end
8 changes: 4 additions & 4 deletions app/tasks/fetch_feed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ def initialize(feed, parser: Feedjira::Feed, logger: nil)
def fetch
begin
options = {
user_agent: USER_AGENT,
if_modified_since: @feed.last_fetched,
timeout: 30,
user_agent: USER_AGENT,
if_modified_since: @feed.last_fetched,
timeout: 30,
max_redirects: 2,
compress: true
}

raw_feed = @parser.fetch_and_parse(@feed.url, options)

if raw_feed == 304
Expand Down
2 changes: 1 addition & 1 deletion app/utils/api_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ class ApiKey
def self.compute(plaintext_password)
Digest::MD5.hexdigest("stringer:#{plaintext_password}")
end
end
end
2 changes: 1 addition & 1 deletion app/utils/opml_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class OpmlParser
def parse_feeds(contents)
doc = Nokogiri.XML(contents)

feeds_with_groups = Hash.new { |h,k| h[k] = [] }
feeds_with_groups = Hash.new { |h, k| h[k] = [] }

doc.xpath('//body/outline').each do |outline|

Expand Down
Loading

0 comments on commit 03686da

Please sign in to comment.