Skip to content
This repository

Minimal fix for warnings #119

Merged
merged 3 commits into from almost 2 years ago

2 participants

Matijs van Zuijlen Christoph Olszowka
Matijs van Zuijlen
mvz commented

These commits turn on warnings to demonstrate issue #106, and then fix the warnings emitted by rake test. I have attempted to keep the changes as minimal as possible; they basically boil down do inserting a defined? here and there.

Note: shoulda (or shoulda-context depending on which version is in your Gemfile.lock) will still emit some warnings during the running of the tests.

Christoph Olszowka colszowka merged commit f901802 into from
Christoph Olszowka colszowka closed this
Christoph Olszowka
Owner

Merged and will be part of the next release. Thanks for your effort! I'll add some further comment into #106

Jonathan Perkin jperkin referenced this pull request from a commit in joyent/pkgsrc
Update ruby-simplecov to 0.6.4.
v0.6.4, 2012-05-10 ([changes](colszowka/simplecov@v0.6.3...v0.6.4))
-------------------

  * [BUGFIX] Encoding issues with ISO-8859-encoded source files fixed.
    See colszowka/simplecov#117. (thanks to @Deradon)
  * [BUGFIX] Ensure ZeroDivisionErrors won't occur when calculating the coverage result, which previously
    could happen in certain cases. See colszowka/simplecov#128. (thanks to @japgolly)
  * [REFACTORING] Changed a couple instance variable lookups so SimpleCov does not cause a lot of warnings when
    running ruby at a higher warning level. See colszowka/simplecov#106 and
    colszowka/simplecov#119. (thanks to @mvz and @gioele)


v0.6.3, 2012-05-10 ([changes](colszowka/simplecov@v0.6.2...v0.6.3))
-------------------

  * [BUGFIX] Modified the API-changes for newer multi_json versions introduced with #122 and v0.6.2 so
    they are backwards-compatible with older multi_json gems in order to avoid simplecov polluting
    the multi_json minimum version requirement for entire applications.
    See colszowka/simplecov#132
  * Added appraisal gem to the test setup in order to run the test suite against both 1.0 and 1.3
    multi_json gems and ensure the above actually works :)
0410186
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
1  Rakefile
@@ -8,6 +8,7 @@ Rake::TestTask.new(:test) do |test|
8 8
   test.libs << 'lib' << 'test'
9 9
   test.test_files = FileList['test/test_*.rb']
10 10
   test.verbose = true
  11
+  test.warning = true
11 12
 end
12 13
 
13 14
 require 'cucumber/rake/task'
2  lib/simplecov.rb
@@ -48,7 +48,7 @@ def result
48 48
         SimpleCov::ResultMerger.store_result(@result) if @result
49 49
         return SimpleCov::ResultMerger.merged_result
50 50
       else
51  
-        return @result
  51
+        return @result if defined? @result
52 52
       end
53 53
     ensure
54 54
       self.running = false
8  lib/simplecov/configuration.rb
@@ -14,7 +14,7 @@ module SimpleCov::Configuration
14 14
   # Configure with SimpleCov.root('/my/project/path')
15 15
   #
16 16
   def root(root=nil)
17  
-    return @root if @root and root.nil?
  17
+    return @root if defined? @root and root.nil?
18 18
     @root = File.expand_path(root || Dir.getwd)
19 19
   end
20 20
 
@@ -24,7 +24,7 @@ def root(root=nil)
24 24
   # Configure with SimpleCov.coverage_dir('cov')
25 25
   #
26 26
   def coverage_dir(dir=nil)
27  
-    return @coverage_dir if @coverage_dir and dir.nil?
  27
+    return @coverage_dir if defined? @coverage_dir and dir.nil?
28 28
     @coverage_dir = (dir || 'coverage')
29 29
   end
30 30
 
@@ -67,7 +67,7 @@ def command_name(name=nil)
67 67
   # Configure with: SimpleCov.formatter(SimpleCov::Formatter::SimpleFormatter)
68 68
   #
69 69
   def formatter(formatter=nil)
70  
-    return @formatter if @formatter and formatter.nil?
  70
+    return @formatter if defined? @formatter and formatter.nil?
71 71
     @formatter = formatter
72 72
     raise "No formatter configured. Please specify a formatter using SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter" unless @formatter
73 73
     @formatter
@@ -81,7 +81,7 @@ def formatter(formatter=nil)
81 81
   # Configure with SimpleCov.nocov_token('skip') or it's alias SimpleCov.skip_token('skip')
82 82
   #
83 83
   def nocov_token(nocov_token=nil)
84  
-    return @nocov_token if @nocov_token and nocov_token.nil?
  84
+    return @nocov_token if defined? @nocov_token and nocov_token.nil?
85 85
     @nocov_token = (nocov_token || 'nocov')
86 86
   end
87 87
   alias_method :skip_token, :nocov_token
4  lib/simplecov/result.rb
@@ -58,7 +58,7 @@ def covered_strength
58 58
 
59 59
     # Returns the count of lines that are covered
60 60
     def covered_lines
61  
-      return @covered_lines if @covered_lines
  61
+      return @covered_lines if defined? @covered_lines
62 62
       @covered_lines = 0
63 63
       @files.each do |file|
64 64
         original_result[file.filename].each do |line_result|
@@ -70,7 +70,7 @@ def covered_lines
70 70
 
71 71
     # Returns the count of missed lines
72 72
     def missed_lines
73  
-      return @missed_lines if @missed_lines
  73
+      return @missed_lines if defined? @missed_lines
74 74
       @missed_lines = 0
75 75
       @files.each do |file|
76 76
         original_result[file.filename].each do |line_result|
2  lib/simplecov/source_file.rb
@@ -84,7 +84,7 @@ def initialize(filename, coverage)
84 84
     # Returns all source lines for this file as instances of SimpleCov::SourceFile::Line,
85 85
     # and thus including coverage data. Aliased as :source_lines
86 86
     def lines
87  
-      return @lines unless @lines.nil?
  87
+      return @lines if defined? @lines
88 88
 
89 89
       # Warning to identify condition from Issue #56
90 90
       if coverage.size > src.size
2  test/test_source_file.rb
@@ -68,7 +68,7 @@ class TestSourceFile < Test::Unit::TestCase
68 68
           @source_file.lines
69 69
         end
70 70
 
71  
-        assert_match /^Warning: coverage data provided/, captured_output
  71
+        assert_match(/^Warning: coverage data provided/, captured_output)
72 72
       end
73 73
     end
74 74
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.