Permalink
Browse files

Correct most of Rubocop offenses

  • Loading branch information...
1 parent 5b02ad9 commit 388ff1a24373c8e669bfce56d10bb7b38dc7f28d @syndbg syndbg committed Oct 2, 2015
View
@@ -5,21 +5,23 @@ gem 'responders'
gem 'uglifier'
gem 'jquery-rails'
gem 'less-rails'
-gem 'therubyracer', :platforms => :ruby
+gem 'therubyracer', platforms: :ruby
gem 'bootstrap-on-rails'
gem 'turbolinks'
gem 'pg'
gem 'puma'
gem 'slim-rails'
gem 'git'
-gem 'appconfig', :require => 'app_config'
+gem 'appconfig', require: 'app_config'
gem 'sidekiq'
gem 'sidetiq' # Recurring jobs
-gem 'sinatra', '>= 1.3.0', :require => nil
+gem 'sinatra', '>= 1.3.0', require: nil
gem 'newrelic_rpm'
gem 'nokogiri'
-gem 'open_uri_redirections' # open-uri library patched to follow http to https redirects
-gem 'array_is_uniq', :require => 'array' # Implemented the missing unqi? method on Ruby Arrays
+# open-uri library patched to follow http to https redirects
+gem 'open_uri_redirections'
+# Implemented the missing uniq? method on Ruby Arrays
+gem 'array_is_uniq', require: 'array'
gem 'pluralize_no_count_if_one'
gem 'quiet_assets'
@@ -29,23 +31,23 @@ end
group :development do
gem 'better_errors'
- gem 'binding_of_caller', :platforms=>[:mri_19, :mri_20, :rbx]
- gem 'hub', :require => nil
+ gem 'binding_of_caller', platforms: [:mri_19, :mri_20, :rbx]
+ gem 'hub', require: nil
gem 'rails_layout'
gem 'yard'
gem 'rails_best_practices'
- gem 'rubocop'
+ gem 'rubocop', require: false
end
group :test, :cucumber do
gem 'capybara'
- gem 'cucumber-rails', :require => false
+ gem 'cucumber-rails', require: false
gem 'database_cleaner'
gem 'email_spec'
gem 'launchy'
gem 'rspec-rails'
gem 'shoulda-matchers'
- gem 'cucumber-timecop', '0.0.3', :require => false
+ gem 'cucumber-timecop', '0.0.3', require: false
gem 'rake'
gem 'webmock'
gem 'coveralls', require: false
@@ -27,10 +27,10 @@ def refresh_description
def search
@formulas = Homebrew::Formula.active_or_external.where(
- 'filename iLIKE ? OR name iLIKE ?',
- "%#{params[:search][:term]}%",
- "%#{params[:search][:term]}%"
- ).order(:name)
+ 'filename iLIKE ? OR name iLIKE ?',
+ "%#{params[:search][:term]}%",
+ "%#{params[:search][:term]}%"
+ ).order(:name)
end
private
@@ -40,10 +40,10 @@ def current_object
params[:id].downcase).first!
rescue ActiveRecord::RecordNotFound
respond_to do |format|
- format.html {
+ format.html do
flash[:error] = 'This formula doesn\'t exists'
redirect_to root_url
- }
+ end
format.json { respond_with({}, status: :not_found) }
end
end
@@ -54,12 +54,10 @@ def current_objects
def calculate_percentage
with_a_description_count = Homebrew::Formula.internals
- .with_a_description.count
+ .with_a_description.count
@coverage = 0
-
- unless with_a_description_count.zero? || @formulas.size.zero?
- @coverage = (with_a_description_count * 100) / @formulas.size
- end
+ @coverage = (with_a_description_count * 100) / @formulas.size unless
+ with_a_description_count.zero? || @formulas.size.zero?
end
def new_since_a_week
@@ -78,13 +76,13 @@ def first_import_end_date
def respond_with_format
respond_to do |format|
format.html
- format.json {
+ format.json do
if action_name == 'show'
respond_with(@formula, status: :ok)
else
respond_with([], status: 415)
end
- }
+ end
end
end
end
@@ -118,16 +118,14 @@ def update_description_from!(html)
description = Homebrew::Formula::Description.new(self)
description.lookup_from(html)
- # In the case a description has been found
- if description.found?
- unless update_attributes(
- description: description.text,
- description_automatic: true
- )
- Rails.logger.warn 'Unable to update description with text ' \
- "#{description.text}"
- end
- end
+ return unless description.found?
+ return if update_attributes(
+ description: description.text,
+ description_automatic: true
+ )
+
+ Rails.logger.warn 'Unable to update description with text ' \
+ "#{description.text}"
end
def reference
@@ -142,7 +140,7 @@ def new?
created_at.to_date == Time.now.utc.to_date
end
- def as_json(options = {})
+ def as_json(_options = {}) # rubocop:disable Metrics/AbcSize
{
formula: name.downcase,
description: description.to_s,
@@ -152,7 +150,7 @@ def as_json(options = {})
dependencies: dependencies.map(&:name).sort,
dependents: formula_dependents.map(&:formula).map(&:name).sort
}
- end
+ end # rubocop:enable Metrics/AbcSize
private
@@ -58,7 +58,7 @@ def self.get_conflicts(formula)
conflicts.gsub!(/('|")/, '')
- conflicts, _ = extract_conflict_reason_if_possible!(conflicts)
+ conflicts, = extract_conflict_reason_if_possible!(conflicts)
conflicting_formulas = conflicts.strip.split(',').map(&:strip)
conflicting_formulas.map do |name|
@@ -29,7 +29,6 @@ def fetch
private
-
#
# Fetch the HTML content from a given URL
# @param url [String] URL from where to fetch the content
@@ -11,7 +11,8 @@ def initialize(nokogiri_html, options = {})
fail ArgumentError, 'You must provide a name and a filename'
end
- @software_name, @software_filename = options[:name], options[:filename]
+ @software_name = options[:name]
+ @software_filename = options[:filename]
@html = nokogiri_html
end
@@ -29,10 +30,10 @@ def clean_text(text)
end
def regex
- /(^.*(?:#{@software_name}|#{@software_filename})
+ %r{(^.*(?:#{@software_name}|#{@software_filename})
(?:\)|\s\u2122|\s[\d\.]+|\scodec)?\s(?:is\s
(?:an?|the)|(?:project\s)?provides)[\s\w\'\(\)\,\-\+\/\.\:]+\.(?:\s|$)
- )/ix
+ )}ix
end
def look_html_body
View
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
-APP_PATH = File.expand_path('../../config/application', __FILE__)
+APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
View
@@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.
-require ::File.expand_path('../config/environment', __FILE__)
+require ::File.expand_path('../config/environment', __FILE__)
run Rails.application
View
@@ -50,7 +50,6 @@
set :puma_preload_app, true
namespace :deploy do
-
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
@@ -69,5 +68,4 @@
# end
end
end
-
end
@@ -26,7 +26,7 @@
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
- config.assets.debug = true # Send email in development mode.
+ config.assets.debug = true # Send email in development mode.
config.action_mailer.perform_deliveries = true
# Precompiled assets always have a digest now
@@ -1,7 +1,5 @@
# When running on Tutum.co platform, redirect the logs to the standard output
# so that they are accessible from the Tutum.co dashboard
-if ENV.key?('TUTUM')
- Rails.logger = Logger.new(STDOUT)
-end
+Rails.logger = Logger.new(STDOUT) if ENV.key?('TUTUM')
-Rails.logger.info "Tutum initialization done."
+Rails.logger.info 'Tutum initialization done.'
@@ -1,21 +1,22 @@
namespace :brewformulas do
- desc "Dump Formula homepage into a fixture file"
- task :dump_homepage, [:formula_name] => [:environment] do |t, args|
+ desc 'Dump Formula homepage into a fixture file'
+ task :dump_homepage, [:formula_name] => [:environment] do |_t, args|
formula = Homebrew::Formula.find_by!(name: args[:formula_name])
- raise "Formula #{formula.name} has no homepage!" unless formula.homepage
+ fail "Formula #{formula.name} has no homepage!" unless formula.homepage
- fixture_path = Rails.root.join("features", "fixtures", "webmock", formula.name.downcase)
- raise "A fixture file already exists for Formula #{formula.name}!" if File.exists?(fixture_path)
+ fixture_path = Rails.root.join('features', 'fixtures',
+ 'webmock', formula.name.downcase)
+ fail "A fixture file already exists for Formula #{formula.name}!" if File.exist?(fixture_path)
- puts "Getting homepage..."
+ puts 'Getting homepage...'
homepage = Homepage.new(formula.homepage)
- puts "Saving homepage..."
- FileUtils.mkdir_p(fixture_path) unless File.exists?(fixture_path)
- File.open(File.join(fixture_path, "index.html"), "w") {|file|
+ puts 'Saving homepage...'
+ FileUtils.mkdir_p(fixture_path) unless File.exist?(fixture_path)
+ File.open(File.join(fixture_path, 'index.html'), 'w') do|file|
file.write(homepage.fetch)
- }
+ end
puts "#{formula.name}'s homepage successfully dumped in #{fixture_path}."
end
end
@@ -1,8 +1,9 @@
begin
require 'coveralls/rake/task'
Coveralls::RakeTask.new
- task :default => [:spec, :cucumber, 'coveralls:push']
+ task default: [:spec, :cucumber, 'coveralls:push']
rescue LoadError
+ puts 'not loading coveralls'
# When loading this file out of the test profile
# coveralls is not installed
end
@@ -4,62 +4,61 @@
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
+unless ARGV.any? { |a| a =~ /^gems/ } # Don't load anything when running the gems:* tasks
-unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
+ vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
+ $LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
-vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
-$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
+ begin
+ require 'cucumber/rake/task'
-begin
- require 'cucumber/rake/task'
+ namespace :cucumber do
+ Cucumber::Rake::Task.new({ ok: 'test:prepare' }, 'Run features that should pass') do |t|
+ t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
+ t.fork = true # You may get faster startup if you set this to false
+ t.profile = 'default'
+ end
- namespace :cucumber do
- Cucumber::Rake::Task.new({:ok => 'test:prepare'}, 'Run features that should pass') do |t|
- t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
- t.fork = true # You may get faster startup if you set this to false
- t.profile = 'default'
- end
-
- Cucumber::Rake::Task.new({:wip => 'test:prepare'}, 'Run features that are being worked on') do |t|
- t.binary = vendored_cucumber_bin
- t.fork = true # You may get faster startup if you set this to false
- t.profile = 'wip'
- end
+ Cucumber::Rake::Task.new({ wip: 'test:prepare' }, 'Run features that are being worked on') do |t|
+ t.binary = vendored_cucumber_bin
+ t.fork = true # You may get faster startup if you set this to false
+ t.profile = 'wip'
+ end
- Cucumber::Rake::Task.new({:rerun => 'test:prepare'}, 'Record failing features and run only them if any exist') do |t|
- t.binary = vendored_cucumber_bin
- t.fork = true # You may get faster startup if you set this to false
- t.profile = 'rerun'
- end
+ Cucumber::Rake::Task.new({ rerun: 'test:prepare' }, 'Record failing features and run only them if any exist') do |t|
+ t.binary = vendored_cucumber_bin
+ t.fork = true # You may get faster startup if you set this to false
+ t.profile = 'rerun'
+ end
- desc 'Run all features'
- task :all => [:ok, :wip]
+ desc 'Run all features'
+ task all: [:ok, :wip]
- task :statsetup do
- require 'rails/code_statistics'
- ::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
- ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
+ task :statsetup do
+ require 'rails/code_statistics'
+ ::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
+ ::CodeStatistics::TEST_TYPES << 'Cucumber features' if File.exist?('features')
+ end
end
- end
- desc 'Alias for cucumber:ok'
- task :cucumber => 'cucumber:ok'
+ desc 'Alias for cucumber:ok'
+ task cucumber: 'cucumber:ok'
- task :default => :cucumber
+ task default: :cucumber
- task :features => :cucumber do
- STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
- end
+ task features: :cucumber do
+ STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
+ end
- # In case we don't have the generic Rails test:prepare hook, append a no-op task that we can depend upon.
- task 'test:prepare' do
- end
+ # In case we don't have the generic Rails test:prepare hook, append a no-op task that we can depend upon.
+ task 'test:prepare' do
+ end
- task :stats => 'cucumber:statsetup'
-rescue LoadError
- desc 'cucumber rake task not available (cucumber not installed)'
- task :cucumber do
- abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
+ task stats: 'cucumber:statsetup'
+ rescue LoadError
+ desc 'cucumber rake task not available (cucumber not installed)'
+ task :cucumber do
+ abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
+ end
end
-end
end
Oops, something went wrong.

0 comments on commit 388ff1a

Please sign in to comment.