Fix more offenses.

parent 1f5a9d6a
# This configuration was generated by
# `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
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
......@@ -43,12 +43,6 @@ Lint/DuplicateMethods:
Lint/EndAlignment:
Enabled: false
# Offense count: 2
Lint/HandleExceptions:
Exclude:
- 'Rakefile'
- 'lib/annotate.rb'
# Offense count: 6
Lint/IneffectiveAccessModifier:
Exclude:
......@@ -90,15 +84,7 @@ Lint/UselessAccessModifier:
- 'lib/annotate/annotate_routes.rb'
- 'spec/integration/common_validation.rb'
# Offense count: 7
Lint/UselessAssignment:
Exclude:
- 'Rakefile'
- 'lib/annotate/annotate_models.rb'
- 'spec/integration/common_validation.rb'
- 'spec/integration/integration_spec.rb'
# Offense count: 17
# Offense count: 18
Metrics/AbcSize:
Max: 157
......@@ -249,13 +235,12 @@ Style/CommentIndentation:
Exclude:
- 'lib/annotate/annotate_routes.rb'
# Offense count: 3
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: SingleLineConditionsOnly.
Style/ConditionalAssignment:
Exclude:
- 'lib/annotate/annotate_models.rb'
- 'spec/integration/common_validation.rb'
# Offense count: 2
# Cop supports --auto-correct.
......@@ -366,7 +351,7 @@ Style/GuardClause:
- 'lib/annotate/annotate_models.rb'
- 'spec/integration/rails_2.3_with_bundler/config/boot.rb'
# Offense count: 142
# Offense count: 135
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
# SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets
......@@ -378,12 +363,11 @@ Style/IfInsideElse:
Exclude:
- 'lib/annotate/annotate_routes.rb'
# Offense count: 6
# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
Exclude:
- 'Rakefile'
- 'lib/annotate.rb'
- 'lib/annotate/annotate_models.rb'
......@@ -473,7 +457,7 @@ Style/MutableConstant:
- 'spec/integration/rails_2.3_with_bundler/config/environment.rb'
- 'spec/spec_helper.rb'
# Offense count: 7
# Offense count: 6
# Cop supports --auto-correct.
Style/NegatedIf:
Exclude:
......@@ -634,7 +618,7 @@ Style/SpaceAfterComma:
Exclude:
- 'lib/annotate/annotate_models.rb'
# Offense count: 50
# Offense count: 44
# Cop supports --auto-correct.
Style/SpaceAfterControlKeyword:
Exclude:
......@@ -719,7 +703,7 @@ Style/SpaceInsideStringInterpolation:
Style/SpecialGlobalVars:
EnforcedStyle: use_perl_names
# Offense count: 373
# Offense count: 363
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
......@@ -785,13 +769,12 @@ Style/TrailingCommaInLiteral:
- 'lib/annotate/annotate_models.rb'
- 'spec/annotate/annotate_models_spec.rb'
# Offense count: 4
# Offense count: 3
# Cop supports --auto-correct.
Style/TrailingWhitespace:
Exclude:
- 'lib/annotate.rb'
- 'spec/annotate/annotate_models_spec.rb'
- 'spec/integration/integration_spec.rb'
- 'spec/integration/rails_2.3_with_bundler/db/schema.rb'
# 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
begin
require 'bundler'
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
$stderr.puts 'Run `bundle install` to install missing gems'
exit_exception(e)
end
using_dsl = false
......@@ -14,18 +18,16 @@ begin
using_dsl = true
rescue Exception => e
# We might just be on an old version of Rake...
exit_exception(e)
end
require 'rake'
if(using_dsl)
include Rake::DSL
end
include Rake::DSL if using_dsl
require "./lib/annotate"
require "mg"
require './lib/annotate'
require 'mg'
begin
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.")
# Gemspec is probably in a broken state, so let's give ourselves a chance to
# build a new one...
......@@ -88,7 +90,7 @@ namespace :jeweler do
FileUtils.rm_f("pkg")
end
end
task :clobber => :'jeweler:clobber'
task clobber: :'jeweler:clobber'
require "rspec/core/rake_task" # RSpec 2.0
RSpec::Core::RakeTask.new(:spec) do |t|
......@@ -111,7 +113,7 @@ namespace :gemsets do
end
end
end
task :clobber => :'gemsets:empty'
task clobber: :'gemsets:empty'
namespace :integration do
desc "Remove any cruft generated by manual debugging runs which is .gitignore'd."
......@@ -120,19 +122,19 @@ namespace :integration do
end
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.clear_untracked_files
end
task :symlink => [:integration_environment] do
task symlink: [:integration_environment] do
require 'digest/md5'
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'])
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 "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)
candidates = {}
FileList[
"#{target_dir}/.rvmrc",
......@@ -156,7 +158,7 @@ namespace :integration do
candidates[digest] << fname
end
fixtures = {}
FileList["spec/fixtures/**/*"].each do |fname|
FileList['spec/fixtures/**/*'].each do |fname|
fixtures[Digest::MD5.hexdigest(File.read(fname))] = File.expand_path(fname)
end
......@@ -190,7 +192,7 @@ namespace :yard do
FileUtils.rm_f("doc")
end
end
task :clobber => :'yard:clobber'
task clobber: :'yard:clobber'
namespace :rubinius do
task :clobber do
......@@ -198,7 +200,7 @@ namespace :rubinius do
FileList[".rbx/**/*"].each { |fname| FileUtils.rm_f(fname) }
end
end
task :clobber => :'rubinius:clobber'
task clobber: :'rubinius:clobber'
# want other tests/tasks run by default? Add them to the list
task :default => [:spec]
task default: [:spec]
......@@ -158,20 +158,23 @@ module Annotate
def self.bootstrap_rake
begin
require 'rake/dsl_definition'
rescue Exception
rescue Exception => e
# We might just be on an old version of Rake...
puts e.message
exit e.status_code
end
require 'rake'
load './Rakefile' if File.exist?('./Rakefile')
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
# ActiveSupport we need.
require 'active_support'
require 'active_support/core_ext/class/subclasses'
require 'active_support/core_ext/string/inflections'
end
self.load_tasks
Rake::Task[:set_annotation_options].invoke
end
......
......@@ -628,12 +628,12 @@ module AnnotateModels
associations = []
id = nil
cols = cols.each do |c|
if c.name.eql?("id")
cols.each do |c|
if c.name.eql?('id')
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
elsif c.name[-3,3].eql?("_id")
elsif c.name[-3,3].eql?('_id')
associations << c
else
rest_cols << c
......
......@@ -57,10 +57,10 @@ module Annotate
def self.apply_annotation(test_rig, fname, annotation, place_before=true)
corpus = File.read(File.join(test_rig, fname))
if(place_before)
corpus = annotation + "\n" + corpus
if place_before
annotation + "\n" + corpus
else
corpus = corpus + "\n" + annotation
corpus + "\n" + annotation
end
end
end
......
......@@ -16,25 +16,23 @@ ENV['rvm_pretty_print_flag'] = '0'
ENV['BUNDLE_GEMFILE'] = './Gemfile'
describe "annotate inside Rails, using #{CURRENT_RUBY}" do
here = File.expand_path('..', __FILE__)
chosen_scenario = nil
if(!ENV['SCENARIO'].blank?)
if !ENV['SCENARIO'].blank?
chosen_scenario = File.expand_path(ENV['SCENARIO'])
raise "Can't find specified scenario '#{chosen_scenario}'!" unless(File.directory?(chosen_scenario))
end
Annotate::Integration::SCENARIOS.each do |test_rig, base_dir, test_name|
next if(chosen_scenario && chosen_scenario != test_rig)
it "works under #{test_name}" do
if(!USING_RVM)
skip "Must have RVM installed."
if !USING_RVM
skip 'Must have RVM installed.'
next
end
# Don't proceed if the working copy is dirty!
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
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