Fix more offenses.

parent 1f5a9d6a
# This configuration was generated by # This configuration was generated by
# `rubocop --auto-gen-config` # `rubocop --auto-gen-config`
# on 2016-01-19 22:54:29 +0100 using RuboCop version 0.36.0. # on 2016-01-19 23:11:26 +0100 using RuboCop version 0.36.0.
# The point is for the user to remove these configuration records # The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base. # one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new # Note that changes in the inspected code, or installation of new
...@@ -43,12 +43,6 @@ Lint/DuplicateMethods: ...@@ -43,12 +43,6 @@ Lint/DuplicateMethods:
Lint/EndAlignment: Lint/EndAlignment:
Enabled: false Enabled: false
# Offense count: 2
Lint/HandleExceptions:
Exclude:
- 'Rakefile'
- 'lib/annotate.rb'
# Offense count: 6 # Offense count: 6
Lint/IneffectiveAccessModifier: Lint/IneffectiveAccessModifier:
Exclude: Exclude:
...@@ -90,15 +84,7 @@ Lint/UselessAccessModifier: ...@@ -90,15 +84,7 @@ Lint/UselessAccessModifier:
- 'lib/annotate/annotate_routes.rb' - 'lib/annotate/annotate_routes.rb'
- 'spec/integration/common_validation.rb' - 'spec/integration/common_validation.rb'
# Offense count: 7 # Offense count: 18
Lint/UselessAssignment:
Exclude:
- 'Rakefile'
- 'lib/annotate/annotate_models.rb'
- 'spec/integration/common_validation.rb'
- 'spec/integration/integration_spec.rb'
# Offense count: 17
Metrics/AbcSize: Metrics/AbcSize:
Max: 157 Max: 157
...@@ -249,13 +235,12 @@ Style/CommentIndentation: ...@@ -249,13 +235,12 @@ Style/CommentIndentation:
Exclude: Exclude:
- 'lib/annotate/annotate_routes.rb' - 'lib/annotate/annotate_routes.rb'
# Offense count: 3 # Offense count: 2
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: SingleLineConditionsOnly. # Configuration parameters: SingleLineConditionsOnly.
Style/ConditionalAssignment: Style/ConditionalAssignment:
Exclude: Exclude:
- 'lib/annotate/annotate_models.rb' - 'lib/annotate/annotate_models.rb'
- 'spec/integration/common_validation.rb'
# Offense count: 2 # Offense count: 2
# Cop supports --auto-correct. # Cop supports --auto-correct.
...@@ -366,7 +351,7 @@ Style/GuardClause: ...@@ -366,7 +351,7 @@ Style/GuardClause:
- 'lib/annotate/annotate_models.rb' - 'lib/annotate/annotate_models.rb'
- 'spec/integration/rails_2.3_with_bundler/config/boot.rb' - 'spec/integration/rails_2.3_with_bundler/config/boot.rb'
# Offense count: 142 # Offense count: 135
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues. # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
# SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets # SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets
...@@ -378,12 +363,11 @@ Style/IfInsideElse: ...@@ -378,12 +363,11 @@ Style/IfInsideElse:
Exclude: Exclude:
- 'lib/annotate/annotate_routes.rb' - 'lib/annotate/annotate_routes.rb'
# Offense count: 6 # Offense count: 5
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: MaxLineLength. # Configuration parameters: MaxLineLength.
Style/IfUnlessModifier: Style/IfUnlessModifier:
Exclude: Exclude:
- 'Rakefile'
- 'lib/annotate.rb' - 'lib/annotate.rb'
- 'lib/annotate/annotate_models.rb' - 'lib/annotate/annotate_models.rb'
...@@ -473,7 +457,7 @@ Style/MutableConstant: ...@@ -473,7 +457,7 @@ Style/MutableConstant:
- 'spec/integration/rails_2.3_with_bundler/config/environment.rb' - 'spec/integration/rails_2.3_with_bundler/config/environment.rb'
- 'spec/spec_helper.rb' - 'spec/spec_helper.rb'
# Offense count: 7 # Offense count: 6
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/NegatedIf: Style/NegatedIf:
Exclude: Exclude:
...@@ -634,7 +618,7 @@ Style/SpaceAfterComma: ...@@ -634,7 +618,7 @@ Style/SpaceAfterComma:
Exclude: Exclude:
- 'lib/annotate/annotate_models.rb' - 'lib/annotate/annotate_models.rb'
# Offense count: 50 # Offense count: 44
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/SpaceAfterControlKeyword: Style/SpaceAfterControlKeyword:
Exclude: Exclude:
...@@ -719,7 +703,7 @@ Style/SpaceInsideStringInterpolation: ...@@ -719,7 +703,7 @@ Style/SpaceInsideStringInterpolation:
Style/SpecialGlobalVars: Style/SpecialGlobalVars:
EnforcedStyle: use_perl_names EnforcedStyle: use_perl_names
# Offense count: 373 # Offense count: 363
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline. # Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes # SupportedStyles: single_quotes, double_quotes
...@@ -785,13 +769,12 @@ Style/TrailingCommaInLiteral: ...@@ -785,13 +769,12 @@ Style/TrailingCommaInLiteral:
- 'lib/annotate/annotate_models.rb' - 'lib/annotate/annotate_models.rb'
- 'spec/annotate/annotate_models_spec.rb' - 'spec/annotate/annotate_models_spec.rb'
# Offense count: 4 # Offense count: 3
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/TrailingWhitespace: Style/TrailingWhitespace:
Exclude: Exclude:
- 'lib/annotate.rb' - 'lib/annotate.rb'
- 'spec/annotate/annotate_models_spec.rb' - 'spec/annotate/annotate_models_spec.rb'
- 'spec/integration/integration_spec.rb'
- 'spec/integration/rails_2.3_with_bundler/db/schema.rb' - 'spec/integration/rails_2.3_with_bundler/db/schema.rb'
# Offense count: 2 # Offense count: 2
......
def exit_exception(e)
$stderr.puts e.message
exit e.status_code
end
# Note : this causes annoying psych warnings under Ruby 1.9.2-p180; to fix, upgrade to 1.9.3 # Note : this causes annoying psych warnings under Ruby 1.9.2-p180; to fix, upgrade to 1.9.3
begin begin
require 'bundler' require 'bundler'
Bundler.setup(:default, :development) Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e rescue Bundler::BundlerError => e
$stderr.puts e.message $stderr.puts 'Run `bundle install` to install missing gems'
$stderr.puts "Run `bundle install` to install missing gems" exit_exception(e)
exit e.status_code
end end
using_dsl = false using_dsl = false
...@@ -14,18 +18,16 @@ begin ...@@ -14,18 +18,16 @@ begin
using_dsl = true using_dsl = true
rescue Exception => e rescue Exception => e
# We might just be on an old version of Rake... # We might just be on an old version of Rake...
exit_exception(e)
end end
require 'rake' require 'rake'
if(using_dsl) include Rake::DSL if using_dsl
include Rake::DSL
end
require "./lib/annotate" require './lib/annotate'
require 'mg'
require "mg"
begin begin
MG.new("annotate.gemspec") MG.new("annotate.gemspec")
rescue Exception => e rescue Exception
STDERR.puts("WARNING: Couldn't read gemspec. As such, a number of tasks may be unavailable to you until you run 'rake gem:gemspec' to correct the issue.") STDERR.puts("WARNING: Couldn't read gemspec. As such, a number of tasks may be unavailable to you until you run 'rake gem:gemspec' to correct the issue.")
# Gemspec is probably in a broken state, so let's give ourselves a chance to # Gemspec is probably in a broken state, so let's give ourselves a chance to
# build a new one... # build a new one...
...@@ -88,7 +90,7 @@ namespace :jeweler do ...@@ -88,7 +90,7 @@ namespace :jeweler do
FileUtils.rm_f("pkg") FileUtils.rm_f("pkg")
end end
end end
task :clobber => :'jeweler:clobber' task clobber: :'jeweler:clobber'
require "rspec/core/rake_task" # RSpec 2.0 require "rspec/core/rake_task" # RSpec 2.0
RSpec::Core::RakeTask.new(:spec) do |t| RSpec::Core::RakeTask.new(:spec) do |t|
...@@ -111,7 +113,7 @@ namespace :gemsets do ...@@ -111,7 +113,7 @@ namespace :gemsets do
end end
end end
end end
task :clobber => :'gemsets:empty' task clobber: :'gemsets:empty'
namespace :integration do namespace :integration do
desc "Remove any cruft generated by manual debugging runs which is .gitignore'd." desc "Remove any cruft generated by manual debugging runs which is .gitignore'd."
...@@ -120,19 +122,19 @@ namespace :integration do ...@@ -120,19 +122,19 @@ namespace :integration do
end end
desc "Reset any changed files, and remove any untracked files in spec/integration/*/, plus run integration:clean." desc "Reset any changed files, and remove any untracked files in spec/integration/*/, plus run integration:clean."
task :clobber => [:integration_environment, :'integration:clean'] do task clobber: [:integration_environment, :'integration:clean'] do
Annotate::Integration.reset_dirty_files Annotate::Integration.reset_dirty_files
Annotate::Integration.clear_untracked_files Annotate::Integration.clear_untracked_files
end end
task :symlink => [:integration_environment] do task symlink: [:integration_environment] do
require 'digest/md5' require 'digest/md5'
integration_dir = File.expand_path(File.join(File.dirname(__FILE__), 'spec', 'integration')) integration_dir = File.expand_path(File.join(File.dirname(__FILE__), 'spec', 'integration'))
fixture_dir = File.expand_path(File.join(File.dirname(__FILE__), 'spec', 'fixtures')) # fixture_dir = File.expand_path(File.join(File.dirname(__FILE__), 'spec', 'fixtures'))
target_dir = File.expand_path(ENV['TARGET']) if(ENV['TARGET']) target_dir = File.expand_path(ENV['TARGET']) if(ENV['TARGET'])
raise "Must specify TARGET=x, where x is an integration test scenario!" unless(target_dir && Dir.exist?(target_dir)) raise "Must specify TARGET=x, where x is an integration test scenario!" unless target_dir && Dir.exist?(target_dir)
raise "TARGET directory must be within spec/integration/!" unless(target_dir.start_with?(integration_dir)) raise "TARGET directory must be within spec/integration/!" unless target_dir.start_with?(integration_dir)
candidates = {} candidates = {}
FileList[ FileList[
"#{target_dir}/.rvmrc", "#{target_dir}/.rvmrc",
...@@ -156,7 +158,7 @@ namespace :integration do ...@@ -156,7 +158,7 @@ namespace :integration do
candidates[digest] << fname candidates[digest] << fname
end end
fixtures = {} fixtures = {}
FileList["spec/fixtures/**/*"].each do |fname| FileList['spec/fixtures/**/*'].each do |fname|
fixtures[Digest::MD5.hexdigest(File.read(fname))] = File.expand_path(fname) fixtures[Digest::MD5.hexdigest(File.read(fname))] = File.expand_path(fname)
end end
...@@ -190,7 +192,7 @@ namespace :yard do ...@@ -190,7 +192,7 @@ namespace :yard do
FileUtils.rm_f("doc") FileUtils.rm_f("doc")
end end
end end
task :clobber => :'yard:clobber' task clobber: :'yard:clobber'
namespace :rubinius do namespace :rubinius do
task :clobber do task :clobber do
...@@ -198,7 +200,7 @@ namespace :rubinius do ...@@ -198,7 +200,7 @@ namespace :rubinius do
FileList[".rbx/**/*"].each { |fname| FileUtils.rm_f(fname) } FileList[".rbx/**/*"].each { |fname| FileUtils.rm_f(fname) }
end end
end end
task :clobber => :'rubinius:clobber' task clobber: :'rubinius:clobber'
# want other tests/tasks run by default? Add them to the list # want other tests/tasks run by default? Add them to the list
task :default => [:spec] task default: [:spec]
...@@ -158,20 +158,23 @@ module Annotate ...@@ -158,20 +158,23 @@ module Annotate
def self.bootstrap_rake def self.bootstrap_rake
begin begin
require 'rake/dsl_definition' require 'rake/dsl_definition'
rescue Exception rescue Exception => e
# We might just be on an old version of Rake... # We might just be on an old version of Rake...
puts e.message
exit e.status_code
end end
require 'rake' require 'rake'
load './Rakefile' if File.exist?('./Rakefile') load './Rakefile' if File.exist?('./Rakefile')
Rake::Task[:environment].invoke rescue nil Rake::Task[:environment].invoke rescue nil
if !defined?(Rails) unless defined?(Rails)
# Not in a Rails project, so time to load up the parts of # Not in a Rails project, so time to load up the parts of
# ActiveSupport we need. # ActiveSupport we need.
require 'active_support' require 'active_support'
require 'active_support/core_ext/class/subclasses' require 'active_support/core_ext/class/subclasses'
require 'active_support/core_ext/string/inflections' require 'active_support/core_ext/string/inflections'
end end
self.load_tasks self.load_tasks
Rake::Task[:set_annotation_options].invoke Rake::Task[:set_annotation_options].invoke
end end
......
...@@ -628,12 +628,12 @@ module AnnotateModels ...@@ -628,12 +628,12 @@ module AnnotateModels
associations = [] associations = []
id = nil id = nil
cols = cols.each do |c| cols.each do |c|
if c.name.eql?("id") if c.name.eql?('id')
id = c id = c
elsif (c.name.eql?("created_at") || c.name.eql?("updated_at")) elsif (c.name.eql?('created_at') || c.name.eql?('updated_at'))
timestamps << c timestamps << c
elsif c.name[-3,3].eql?("_id") elsif c.name[-3,3].eql?('_id')
associations << c associations << c
else else
rest_cols << c rest_cols << c
......
...@@ -57,10 +57,10 @@ module Annotate ...@@ -57,10 +57,10 @@ module Annotate
def self.apply_annotation(test_rig, fname, annotation, place_before=true) def self.apply_annotation(test_rig, fname, annotation, place_before=true)
corpus = File.read(File.join(test_rig, fname)) corpus = File.read(File.join(test_rig, fname))
if(place_before) if place_before
corpus = annotation + "\n" + corpus annotation + "\n" + corpus
else else
corpus = corpus + "\n" + annotation corpus + "\n" + annotation
end end
end end
end end
......
...@@ -16,25 +16,23 @@ ENV['rvm_pretty_print_flag'] = '0' ...@@ -16,25 +16,23 @@ ENV['rvm_pretty_print_flag'] = '0'
ENV['BUNDLE_GEMFILE'] = './Gemfile' ENV['BUNDLE_GEMFILE'] = './Gemfile'
describe "annotate inside Rails, using #{CURRENT_RUBY}" do describe "annotate inside Rails, using #{CURRENT_RUBY}" do
here = File.expand_path('..', __FILE__)
chosen_scenario = nil chosen_scenario = nil
if(!ENV['SCENARIO'].blank?) if !ENV['SCENARIO'].blank?
chosen_scenario = File.expand_path(ENV['SCENARIO']) chosen_scenario = File.expand_path(ENV['SCENARIO'])
raise "Can't find specified scenario '#{chosen_scenario}'!" unless(File.directory?(chosen_scenario)) raise "Can't find specified scenario '#{chosen_scenario}'!" unless(File.directory?(chosen_scenario))
end end
Annotate::Integration::SCENARIOS.each do |test_rig, base_dir, test_name| Annotate::Integration::SCENARIOS.each do |test_rig, base_dir, test_name|
next if(chosen_scenario && chosen_scenario != test_rig) next if(chosen_scenario && chosen_scenario != test_rig)
it "works under #{test_name}" do it "works under #{test_name}" do
if(!USING_RVM) if !USING_RVM
skip "Must have RVM installed." skip 'Must have RVM installed.'
next next
end end
# Don't proceed if the working copy is dirty! # Don't proceed if the working copy is dirty!
expect(Annotate::Integration.is_clean?(test_rig)).to eq(true) expect(Annotate::Integration.is_clean?(test_rig)).to eq(true)
skip "temporarily ignored until Travis can run them" skip 'temporarily ignored until Travis can run them'
Bundler.with_clean_env do Bundler.with_clean_env do
dir base_dir do dir base_dir do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment