Skip to content

Commit 9ba5d51

Browse files
committed
Fixed Offenses.
Added coveralls and code climate gems.
1 parent 82d7ac5 commit 9ba5d51

File tree

4 files changed

+26
-22
lines changed

4 files changed

+26
-22
lines changed

.rubocop_todo.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2016-01-19 23:11:26 +0100 using RuboCop version 0.36.0.
3+
# on 2016-01-19 23:50:34 +0100 using RuboCop version 0.36.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -96,7 +96,7 @@ Metrics/BlockNesting:
9696
Metrics/CyclomaticComplexity:
9797
Max: 36
9898

99-
# Offense count: 290
99+
# Offense count: 292
100100
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
101101
# URISchemes: http, https
102102
Metrics/LineLength:
@@ -110,7 +110,7 @@ Metrics/MethodLength:
110110
# Offense count: 2
111111
# Configuration parameters: CountComments.
112112
Metrics/ModuleLength:
113-
Max: 491
113+
Max: 493
114114

115115
# Offense count: 9
116116
Metrics/PerceivedComplexity:
@@ -344,7 +344,7 @@ Style/FormatString:
344344
Exclude:
345345
- 'lib/annotate/annotate_models.rb'
346346

347-
# Offense count: 6
347+
# Offense count: 5
348348
# Configuration parameters: MinBodyLength.
349349
Style/GuardClause:
350350
Exclude:
@@ -439,11 +439,6 @@ Style/MultilineMethodCallIndentation:
439439
Style/MultilineOperationIndentation:
440440
Enabled: false
441441

442-
# Offense count: 1
443-
Style/MultilineTernaryOperator:
444-
Exclude:
445-
- 'lib/annotate/annotate_models.rb'
446-
447442
# Offense count: 21
448443
# Cop supports --auto-correct.
449444
Style/MutableConstant:
@@ -703,7 +698,7 @@ Style/SpaceInsideStringInterpolation:
703698
Style/SpecialGlobalVars:
704699
EnforcedStyle: use_perl_names
705700

706-
# Offense count: 363
701+
# Offense count: 357
707702
# Cop supports --auto-correct.
708703
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
709704
# SupportedStyles: single_quotes, double_quotes

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ group :development, :test do
1717
gem 'terminal-notifier-guard', require: false
1818
gem 'simplecov', require: false
1919
gem 'rubocop', require: false unless RUBY_VERSION =~ /^1.8/
20+
gem 'coveralls'
21+
gem 'codeclimate-test-reporter'
2022

2123
platforms :mri do
2224
gem 'pry', require: false

lib/annotate/annotate_models.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,14 @@ def annotate_one_file(file_name, info_block, position, options={})
375375
old_content.sub!(magic_comment_matcher, '')
376376
old_content.sub!(PATTERN, '')
377377

378-
new_content = %w(after bottom).include?(options[position].to_s) ?
379-
(magic_comments.join + (old_content.rstrip + "\n\n" + wrapped_info_block)) :
380-
(magic_comments.join + wrapped_info_block + "\n" + old_content)
378+
if %w(after bottom).include?(options[position].to_s)
379+
new_content = magic_comments.join + (old_content.rstrip + "\n\n" + wrapped_info_block)
380+
else
381+
new_content = magic_comments.join + wrapped_info_block + "\n" + old_content
382+
end
381383
end
382384

383-
File.open(file_name, "wb") { |f| f.puts new_content }
385+
File.open(file_name, 'wb') { |f| f.puts new_content }
384386
return true
385387
end
386388
else
@@ -391,14 +393,13 @@ def annotate_one_file(file_name, info_block, position, options={})
391393
def remove_annotation_of_file(file_name)
392394
if File.exist?(file_name)
393395
content = File.read(file_name)
394-
395396
content.sub!(PATTERN, '')
396397

397-
File.open(file_name, "wb") { |f| f.puts content }
398+
File.open(file_name, 'wb') { |f| f.puts content }
398399

399-
return true
400+
true
400401
else
401-
return false
402+
false
402403
end
403404
end
404405

spec/spec_helper.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1+
require 'coveralls'
2+
require 'codeclimate-test-reporter'
13
require 'simplecov'
4+
5+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
6+
Coveralls::SimpleCov::Formatter,
7+
SimpleCov::Formatter::HTMLFormatter,
8+
CodeClimate::TestReporter::Formatter
9+
]
10+
211
SimpleCov.start
312

413
require 'rubygems'
@@ -21,10 +30,7 @@ module Annotate
2130
module Integration
2231
ABSOLUTE_GEM_ROOT=File.expand_path('../../', __FILE__)
2332

24-
CRUFT_PATTERNS=[
25-
"%SCENARIO%/bin/*", "%SCENARIO%/log/*", "%SCENARIO%/tmp/*",
26-
"%SCENARIO%/.bundle"
27-
]
33+
CRUFT_PATTERNS= %w(%SCENARIO%/bin/* %SCENARIO%/log/* %SCENARIO%/tmp/* %SCENARIO%/.bundle)
2834
SCENARIO_HOME=File.join(File.dirname(__FILE__), 'integration')
2935
SCENARIOS=Dir.glob("#{SCENARIO_HOME}/*").
3036
select { |candidate| File.directory?(candidate) }.

0 commit comments

Comments
 (0)