Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

%s/dust/nitpick/g

  • Loading branch information...
commit a0acb7b1b700e1471d16f4632e1db50e99822ac7 1 parent 7760d38
@kevinclark authored
Showing with 220 additions and 220 deletions.
  1. +2 −2 README
  2. +3 −3 Rakefile
  3. +14 −14 bin/nitpick
  4. +21 −21 lib/nitpick.rb
  5. +3 −3 lib/nitpick/argument_nitpicker.rb
  6. +2 −2 lib/nitpick/block_nitpicker.rb
  7. +2 −2 lib/nitpick/branch_nitpicker.rb
  8. +2 −2 lib/nitpick/local_variable_counter.rb
  9. +3 −3 lib/nitpick/local_variable_nitpicker.rb
  10. +2 −2 lib/nitpick/method_nitpicker.rb
  11. +3 −3 lib/nitpick/nitpicker.rb
  12. +2 −2 lib/nitpick/rescue_nitpicker.rb
  13. +1 −1  lib/nitpick/sexp_extension.rb
  14. +1 −1  lib/nitpick/warnings/assignment_as_condition.rb
  15. +1 −1  lib/nitpick/warnings/empty_method.rb
  16. +1 −1  lib/nitpick/warnings/identical_branch.rb
  17. +1 −1  lib/nitpick/warnings/rescue_everything.rb
  18. +1 −1  lib/nitpick/warnings/rescue_value.rb
  19. +1 −1  lib/nitpick/warnings/shadowed_variable.rb
  20. +1 −1  lib/nitpick/warnings/simple_warning.rb
  21. +1 −1  lib/nitpick/warnings/unprotected_block.rb
  22. +1 −1  lib/nitpick/warnings/unused_argument.rb
  23. +1 −1  lib/nitpick/warnings/unused_variable.rb
  24. +1 −1  lib/nitpick/warnings/useless_branch.rb
  25. +37 −37 spec/argument_nitpicker_spec.rb
  26. +3 −3 spec/assignment_as_condition_spec.rb
  27. +14 −14 spec/block_nitpicker_spec.rb
  28. +10 −10 spec/branch_nitpicker_spec.rb
  29. +43 −43 spec/local_variable_nitpicker_spec.rb
  30. +7 −7 spec/method_nitpicker_spec.rb
  31. +4 −4 spec/nitpicker_spec.rb
  32. +10 −10 spec/rescue_nitpicker_spec.rb
  33. +4 −4 spec/rescue_value_spec.rb
  34. +9 −9 spec/shadowed_variable_spec.rb
  35. +5 −5 spec/simple_warning_spec.rb
  36. +1 −1  spec/spec_helper.rb
  37. +2 −2 spec/useless_branch_spec.rb
View
4 README
@@ -1,9 +1,9 @@
Ruby lint. Sorta.
-http://github.com/kevinclark/dust/wikis
+http://github.com/kevinclark/nitpick/wikis
-Clio:dust kev$ ./bin/dust spec/fixtures/block_badness.rb \
+Clio:nitpick kev$ ./bin/nitpick spec/fixtures/block_badness.rb \
> spec/fixtures/branch_badness.rb \
> spec/fixtures/method_badness.rb \
> spec/fixtures/rescue_badness.rb \
View
6 Rakefile
@@ -6,10 +6,10 @@ task :default => :spec
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
- gem.name = "dust"
+ gem.name = "nitpick"
gem.summary = %Q{TODO}
gem.email = "kevin.clark@gmail.com"
- gem.homepage = "http://github.com/kevinclark/dust"
+ gem.homepage = "http://github.com/kevinclark/nitpick"
gem.authors = ["Kevin Clark"]
gem.add_dependency('trollop')
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
@@ -21,7 +21,7 @@ end
require 'rake/rdoctask'
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'dust'
+ rdoc.title = 'nitpick'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
View
28 bin/nitpick
@@ -3,21 +3,21 @@ require 'pp'
require 'rubygems'
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
-require 'dust'
+require 'nitpick'
# {Constant => {Method => [Warnings]}}
$warnings = Hash.new {|h,k| h[k] = Hash.new {|_h,_k| _h[_k] = [] }}
require 'trollop'
opts = Trollop::options do
- opt :only, "Dust only classes/modules that match this string.", :type => :string, :multi => true
- opt :except, "Don't dust classes/modules that match this string.", :type => :string, :multi => true
+ opt :only, "Nitpick only classes/modules that match this string.", :type => :string, :multi => true
+ opt :except, "Don't nitpick classes/modules that match this string.", :type => :string, :multi => true
end
-DustOptions = { :only => opts[:only] || [], :except => opts[:except] || []}
-Dusters = [
- Dust::ArgumentDuster, Dust::BlockDuster, Dust::BranchDuster,
- Dust::LocalVariableDuster, Dust::MethodDuster, Dust::RescueDuster
+NitpickOptions = { :only => opts[:only] || [], :except => opts[:except] || []}
+Nitpickers = [
+ Nitpick::ArgumentNitpicker, Nitpick::BlockNitpicker, Nitpick::BranchNitpicker,
+ Nitpick::LocalVariableNitpicker, Nitpick::MethodNitpicker, Nitpick::RescueNitpicker
]
class Module
@@ -27,13 +27,13 @@ class Module
def method_added(name)
original_method_added(name)
- return if DustOptions[:except].any? {|namespace| /#{namespace}/ =~ self.to_s }
- return unless DustOptions[:only].empty? or DustOptions[:only].any? {|namespace| /#{namespace}/ =~ self.to_s }
+ return if NitpickOptions[:except].any? {|namespace| /#{namespace}/ =~ self.to_s }
+ return unless NitpickOptions[:only].empty? or NitpickOptions[:only].any? {|namespace| /#{namespace}/ =~ self.to_s }
- warnings = Dusters.map do |duster_class|
- duster = duster_class.new(self, name)
- duster.dust!
- duster.warnings
+ warnings = Nitpickers.map do |nitpicker_class|
+ nitpicker = nitpicker_class.new(self, name)
+ nitpicker.nitpick!
+ nitpicker.warnings
end.flatten
$warnings[self.name][name.to_s] = warnings
@@ -73,6 +73,6 @@ ARGV.each do |file|
begin
load file
rescue Exception => e # grab *everything*
- $stderr.puts "*** Dust had trouble loading #{file.inspect}:\n\t#{e.class} #{e.message}"
+ $stderr.puts "*** Nitpick had trouble loading #{file.inspect}:\n\t#{e.class} #{e.message}"
end
end
View
42 lib/nitpick.rb
@@ -4,29 +4,29 @@
require 'parse_tree'
require 'ruby2ruby'
-require 'dust/warnings/simple_warning'
-require 'dust/warnings/unused_variable'
-require 'dust/warnings/unprotected_block'
-require 'dust/warnings/useless_branch'
-require 'dust/warnings/identical_branch'
-require 'dust/warnings/rescue_value'
-require 'dust/warnings/rescue_everything'
-require 'dust/warnings/unused_argument'
-require 'dust/warnings/assignment_as_condition'
-require 'dust/warnings/shadowed_variable'
-require 'dust/warnings/empty_method'
+require 'nitpick/warnings/simple_warning'
+require 'nitpick/warnings/unused_variable'
+require 'nitpick/warnings/unprotected_block'
+require 'nitpick/warnings/useless_branch'
+require 'nitpick/warnings/identical_branch'
+require 'nitpick/warnings/rescue_value'
+require 'nitpick/warnings/rescue_everything'
+require 'nitpick/warnings/unused_argument'
+require 'nitpick/warnings/assignment_as_condition'
+require 'nitpick/warnings/shadowed_variable'
+require 'nitpick/warnings/empty_method'
-require 'dust/duster'
-require 'dust/local_variable_counter'
-require 'dust/local_variable_duster'
-require 'dust/argument_duster'
-require 'dust/block_duster'
-require 'dust/branch_duster'
-require 'dust/rescue_duster'
-require 'dust/method_duster'
+require 'nitpick/nitpicker'
+require 'nitpick/local_variable_counter'
+require 'nitpick/local_variable_nitpicker'
+require 'nitpick/argument_nitpicker'
+require 'nitpick/block_nitpicker'
+require 'nitpick/branch_nitpicker'
+require 'nitpick/rescue_nitpicker'
+require 'nitpick/method_nitpicker'
-require 'dust/sexp_extension'
+require 'nitpick/sexp_extension'
class Sexp
- include Dust::SexpExtension
+ include Nitpick::SexpExtension
end
View
6 lib/nitpick/argument_nitpicker.rb
@@ -1,6 +1,6 @@
-module Dust
- class ArgumentDuster < LocalVariableCounter
- def dust!
+module Nitpick
+ class ArgumentNitpicker < LocalVariableCounter
+ def nitpick!
@silence_warnings = false
super
return if @silence_warnings
View
4 lib/nitpick/block_nitpicker.rb
@@ -1,5 +1,5 @@
-module Dust
- class BlockDuster < Duster
+module Nitpick
+ class BlockNitpicker < Nitpicker
def process_if(exp)
cond = Sexp.from_array(exp.shift)
yes_branch = Sexp.from_array(exp.shift)
View
4 lib/nitpick/branch_nitpicker.rb
@@ -1,5 +1,5 @@
-module Dust
- class BranchDuster < Duster
+module Nitpick
+ class BranchNitpicker < Nitpicker
def process_if(exp)
cond = process(exp.shift)
yes_branch = process(exp.shift)
View
4 lib/nitpick/local_variable_counter.rb
@@ -1,5 +1,5 @@
-module Dust
- class LocalVariableCounter < Duster
+module Nitpick
+ class LocalVariableCounter < Nitpicker
def initialize(klass, meth)
super
# uses.succ each time a local variable is referenced or assigned to
View
6 lib/nitpick/local_variable_nitpicker.rb
@@ -1,6 +1,6 @@
-module Dust
- class LocalVariableDuster < LocalVariableCounter
- def dust!
+module Nitpick
+ class LocalVariableNitpicker < LocalVariableCounter
+ def nitpick!
super
@lvars.each do |name, details|
View
4 lib/nitpick/method_nitpicker.rb
@@ -1,5 +1,5 @@
-module Dust
- class MethodDuster < Duster
+module Nitpick
+ class MethodNitpicker < Nitpicker
def process_defn(exp)
# def foo(x); 1 end =>
# [:defn, :foo, [:scope, [:block, [:args, :x], [:lit, 1]]]]
View
6 lib/nitpick/nitpicker.rb
@@ -1,5 +1,5 @@
-module Dust
- class Duster < SexpProcessor
+module Nitpick
+ class Nitpicker < SexpProcessor
attr_accessor :warnings
def initialize(klass, meth)
@@ -14,7 +14,7 @@ def initialize(klass, meth)
@warnings = []
end
- def dust!
+ def nitpick!
process(ParseTree.translate(@class, @method))
end
View
4 lib/nitpick/rescue_nitpicker.rb
@@ -1,5 +1,5 @@
-module Dust
- class RescueDuster < Duster
+module Nitpick
+ class RescueNitpicker < Nitpicker
def process_resbody(exp)
exceptions = exp.shift
rescue_value = exp.shift
View
2  lib/nitpick/sexp_extension.rb
@@ -1,4 +1,4 @@
-module Dust
+module Nitpick
module SexpExtension
define_method :"!~" do |pattern|
!(self =~ pattern)
View
2  lib/nitpick/warnings/assignment_as_condition.rb
@@ -1,4 +1,4 @@
-module Dust
+module Nitpick
module Warnings
class AssignmentAsCondition < SimpleWarning
ASSIGNMENT_NODES = [:lasgn, :op_asgn_or, :op_asgn_and, :iasgn,
View
2  lib/nitpick/warnings/empty_method.rb
@@ -1,4 +1,4 @@
-module Dust
+module Nitpick
module Warnings
class EmptyMethod < SimpleWarning
attr_reader :body
View
2  lib/nitpick/warnings/identical_branch.rb
@@ -1,4 +1,4 @@
-module Dust
+module Nitpick
module Warnings
class IdenticalBranch < SimpleWarning
attr_reader :yes_branch, :no_branch
View
2  lib/nitpick/warnings/rescue_everything.rb
@@ -1,4 +1,4 @@
-module Dust
+module Nitpick
module Warnings
class RescueEverything < SimpleWarning
def initialize(*args)
View
2  lib/nitpick/warnings/rescue_value.rb
@@ -1,4 +1,4 @@
-module Dust
+module Nitpick
module Warnings
class RescueValue < SimpleWarning
def initialize(*args)
View
2  lib/nitpick/warnings/shadowed_variable.rb
@@ -1,6 +1,6 @@
require 'set'
-module Dust
+module Nitpick
module Warnings
class ShadowedVariable < SimpleWarning
attr_reader :vars
View
2  lib/nitpick/warnings/simple_warning.rb
@@ -1,4 +1,4 @@
-module Dust
+module Nitpick
module Warnings
class SimpleWarning
def self.discover(args = [])
View
2  lib/nitpick/warnings/unprotected_block.rb
@@ -1,4 +1,4 @@
-module Dust
+module Nitpick
module Warnings
class UnprotectedBlock < SimpleWarning
attr_reader :condition, :yes_branch, :no_branch
View
2  lib/nitpick/warnings/unused_argument.rb
@@ -1,4 +1,4 @@
-module Dust
+module Nitpick
module Warnings
class UnusedArgument < SimpleWarning
attr_reader :argument
View
2  lib/nitpick/warnings/unused_variable.rb
@@ -1,4 +1,4 @@
-module Dust
+module Nitpick
module Warnings
class UnusedVariable < SimpleWarning
attr_reader :variable
View
2  lib/nitpick/warnings/useless_branch.rb
@@ -1,4 +1,4 @@
-module Dust
+module Nitpick
module Warnings
class UselessBranch < SimpleWarning
attr_reader :yes_branch, :no_branch
View
74 spec/argument_nitpicker_spec.rb
@@ -4,76 +4,76 @@
include Fixtures
-describe Dust::ArgumentDuster do
+describe Nitpick::ArgumentNitpicker do
it "should create warnings for an unreferenced argument" do
- duster = Dust::ArgumentDuster.new(LocalVariableBadness, :unused_arg)
- duster.dust!
- duster.warnings.should == [Dust::Warnings::UnusedArgument.new(:arg)]
+ nitpicker = Nitpick::ArgumentNitpicker.new(LocalVariableBadness, :unused_arg)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == [Nitpick::Warnings::UnusedArgument.new(:arg)]
end
it "should not create warnings for a referenced argument" do
- duster = Dust::ArgumentDuster.new(LocalVariableBadness, :used_arg)
- duster.dust!
- duster.warnings.should == []
+ nitpicker = Nitpick::ArgumentNitpicker.new(LocalVariableBadness, :used_arg)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == []
end
it "should not create warnings for splat args" do
- duster = Dust::ArgumentDuster.new(LocalVariableBadness, :used_splat_arg)
- duster.dust!
- duster.warnings.should == []
+ nitpicker = Nitpick::ArgumentNitpicker.new(LocalVariableBadness, :used_splat_arg)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == []
end
it "should not create warnings when calling super with no explicit arguments" do
- duster = Dust::ArgumentDuster.new(LocalVariableBadness, :super_with_implicit_args)
- duster.dust!
- duster.warnings.should == []
+ nitpicker = Nitpick::ArgumentNitpicker.new(LocalVariableBadness, :super_with_implicit_args)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == []
end
it "should create warnings when calling super with explicit arguments" do
- duster = Dust::ArgumentDuster.new(LocalVariableBadness, :super_with_explicit_args)
- duster.dust!
- duster.warnings.should == [Dust::Warnings::UnusedArgument.new(:arg)]
+ nitpicker = Nitpick::ArgumentNitpicker.new(LocalVariableBadness, :super_with_explicit_args)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == [Nitpick::Warnings::UnusedArgument.new(:arg)]
end
it "should create warnings when calling super with explicit arguments but without referencing the passed arguments" do
- duster = Dust::ArgumentDuster.new(LocalVariableBadness, :super_with_explicit_args)
- duster.dust!
- duster.warnings.should == [Dust::Warnings::UnusedArgument.new(:arg)]
+ nitpicker = Nitpick::ArgumentNitpicker.new(LocalVariableBadness, :super_with_explicit_args)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == [Nitpick::Warnings::UnusedArgument.new(:arg)]
end
it "should not create warnings for args used with splats" do
- duster = Dust::ArgumentDuster.new(LocalVariableBadness, :args_used_with_splats)
- duster.dust!
- duster.warnings.should == []
+ nitpicker = Nitpick::ArgumentNitpicker.new(LocalVariableBadness, :args_used_with_splats)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == []
end
it "should ignore [:block] arguments in args" do
- duster = Dust::ArgumentDuster.new(LocalVariableBadness, :default_args)
- duster.dust!
- duster.warnings.should == []
+ nitpicker = Nitpick::ArgumentNitpicker.new(LocalVariableBadness, :default_args)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == []
end
it "should handle &block in args when called" do
- duster = Dust::ArgumentDuster.new(LocalVariableBadness, :block_arg_called)
- duster.dust!
- duster.warnings.should == []
+ nitpicker = Nitpick::ArgumentNitpicker.new(LocalVariableBadness, :block_arg_called)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == []
end
it "should handle &block in args when curried" do
- duster = Dust::ArgumentDuster.new(LocalVariableBadness, :block_arg_curried)
- duster.dust!
- duster.warnings.should == []
+ nitpicker = Nitpick::ArgumentNitpicker.new(LocalVariableBadness, :block_arg_curried)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == []
end
it "should warn when &block in args is unused" do
- duster = Dust::ArgumentDuster.new(LocalVariableBadness, :block_arg_unused)
- duster.dust!
- duster.warnings.should == [Dust::Warnings::UnusedArgument.new(:block)]
+ nitpicker = Nitpick::ArgumentNitpicker.new(LocalVariableBadness, :block_arg_unused)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == [Nitpick::Warnings::UnusedArgument.new(:block)]
end
it "shouldn't warn on non-argument variables" do
- duster = Dust::ArgumentDuster.new(LocalVariableBadness, :rescue_to_variable)
- duster.dust!
- duster.warnings.should == []
+ nitpicker = Nitpick::ArgumentNitpicker.new(LocalVariableBadness, :rescue_to_variable)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == []
end
end
View
6 spec/assignment_as_condition_spec.rb
@@ -3,7 +3,7 @@
include Fixtures
-describe Dust::Warnings::AssignmentAsCondition do
+describe Nitpick::Warnings::AssignmentAsCondition do
it "should match against an assignment" do
# TODO(kevinclark):
# This should really include :dasgn, :cvasgn, and :op_asgn2,
@@ -20,7 +20,7 @@
}
matches.each do |_, assignment|
- warning = Dust::Warnings::AssignmentAsCondition.new(assignment)
+ warning = Nitpick::Warnings::AssignmentAsCondition.new(assignment)
warning.matches?.should be_true
end
end
@@ -34,7 +34,7 @@
}
non_matches.each do |_, condition|
- warning = Dust::Warnings::AssignmentAsCondition.new(condition)
+ warning = Nitpick::Warnings::AssignmentAsCondition.new(condition)
warning.matches?.should be_false
end
end
View
28 spec/block_nitpicker_spec.rb
@@ -3,29 +3,29 @@
include Fixtures
-describe Dust::BlockDuster do
+describe Nitpick::BlockNitpicker do
it "should warn when a yield is present without a conditional" do
- duster = Dust::BlockDuster.new(BlockBadness, :no_conditional_for_block_given)
- duster.dust!
- duster.warnings.should == [Dust::Warnings::UnprotectedBlock.new]
+ nitpicker = Nitpick::BlockNitpicker.new(BlockBadness, :no_conditional_for_block_given)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == [Nitpick::Warnings::UnprotectedBlock.new]
end
it "should not warn when there is a check for block_given? before yield" do
- duster = Dust::BlockDuster.new(BlockBadness, :simple_check_for_block_given)
- duster.dust!
- duster.warnings.should == []
+ nitpicker = Nitpick::BlockNitpicker.new(BlockBadness, :simple_check_for_block_given)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == []
end
it "should warn when there is a yield in a conditional without a block_given? check" do
- duster = Dust::BlockDuster.new(BlockBadness, :simple_conditional_without_check)
- duster.dust!
- duster.warnings.size.should == 1
- duster.warnings.first.should be_a_kind_of(Dust::Warnings::UnprotectedBlock)
+ nitpicker = Nitpick::BlockNitpicker.new(BlockBadness, :simple_conditional_without_check)
+ nitpicker.nitpick!
+ nitpicker.warnings.size.should == 1
+ nitpicker.warnings.first.should be_a_kind_of(Nitpick::Warnings::UnprotectedBlock)
end
it "should not warn when there is a check for block_given? in a complex conditional before yield" do
- duster = Dust::BlockDuster.new(BlockBadness, :complex_conditional_with_check)
- duster.dust!
- duster.warnings.should == []
+ nitpicker = Nitpick::BlockNitpicker.new(BlockBadness, :complex_conditional_with_check)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == []
end
end
View
20 spec/branch_nitpicker_spec.rb
@@ -3,22 +3,22 @@
include Fixtures
-describe Dust::BranchDuster do
+describe Nitpick::BranchNitpicker do
it "should warn for a branch simply returning true and false" do
- duster = Dust::BranchDuster.new(BranchBadness, :branch_returning_true_or_false)
- duster.dust!
- duster.warnings.should == [Dust::Warnings::UselessBranch.new]
+ nitpicker = Nitpick::BranchNitpicker.new(BranchBadness, :branch_returning_true_or_false)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == [Nitpick::Warnings::UselessBranch.new]
end
it "should warn for identical branches" do
- duster = Dust::BranchDuster.new(BranchBadness, :branch_returning_identical_things)
- duster.dust!
- duster.warnings.should == [Dust::Warnings::IdenticalBranch.new]
+ nitpicker = Nitpick::BranchNitpicker.new(BranchBadness, :branch_returning_identical_things)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == [Nitpick::Warnings::IdenticalBranch.new]
end
it "should warn for assignments as conditions" do
- duster = Dust::BranchDuster.new(BranchBadness, :branch_with_assignment_as_condition)
- duster.dust!
- duster.warnings.should == [Dust::Warnings::AssignmentAsCondition.new]
+ nitpicker = Nitpick::BranchNitpicker.new(BranchBadness, :branch_with_assignment_as_condition)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == [Nitpick::Warnings::AssignmentAsCondition.new]
end
end
View
86 spec/local_variable_nitpicker_spec.rb
@@ -3,88 +3,88 @@
include Fixtures
-describe Dust::LocalVariableDuster do
+describe Nitpick::LocalVariableNitpicker do
it "should increment uses for an lasgn node" do
- duster = Dust::LocalVariableDuster.new(LocalVariableBadness, :unused_lasgn)
- duster.dust!
- duster.uses(:bar).should == 1
+ nitpicker = Nitpick::LocalVariableNitpicker.new(LocalVariableBadness, :unused_lasgn)
+ nitpicker.nitpick!
+ nitpicker.uses(:bar).should == 1
end
it "should increment uses for an lvar node" do
- duster = Dust::LocalVariableDuster.new(LocalVariableBadness, :used_lvar)
- duster.dust!
- duster.uses(:bar).should == 2 # lvar + lasgn
+ nitpicker = Nitpick::LocalVariableNitpicker.new(LocalVariableBadness, :used_lvar)
+ nitpicker.nitpick!
+ nitpicker.uses(:bar).should == 2 # lvar + lasgn
end
it "should create warnings for an an assigned but unused local variable" do
- duster = Dust::LocalVariableDuster.new(LocalVariableBadness, :unused_lasgn)
- duster.dust!
- duster.warnings.should == [Dust::Warnings::UnusedVariable.new(:bar)]
+ nitpicker = Nitpick::LocalVariableNitpicker.new(LocalVariableBadness, :unused_lasgn)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == [Nitpick::Warnings::UnusedVariable.new(:bar)]
end
it "should not create warnings for used local variables" do
- duster = Dust::LocalVariableDuster.new(LocalVariableBadness, :used_lvar)
- duster.dust!
- duster.warnings.should == []
+ nitpicker = Nitpick::LocalVariableNitpicker.new(LocalVariableBadness, :used_lvar)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == []
end
it "should not create warnings for local variables with calls" do
- duster = Dust::LocalVariableDuster.new(LocalVariableBadness, :lvar_with_call)
- duster.dust!
- duster.warnings.should == []
+ nitpicker = Nitpick::LocalVariableNitpicker.new(LocalVariableBadness, :lvar_with_call)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == []
end
it "should not create warnings for local variables with iasgns" do
- duster = Dust::LocalVariableDuster.new(LocalVariableBadness, :lvar_with_iasgn)
- duster.dust!
- duster.warnings.should == []
+ nitpicker = Nitpick::LocalVariableNitpicker.new(LocalVariableBadness, :lvar_with_iasgn)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == []
end
it "should not create warnings for arguments with iasgns" do
- duster = Dust::LocalVariableDuster.new(LocalVariableBadness, :arg_with_iasgn)
- duster.dust!
- duster.warnings.should == []
+ nitpicker = Nitpick::LocalVariableNitpicker.new(LocalVariableBadness, :arg_with_iasgn)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == []
end
it "should warn when a block variable shadows a local variable" do
- duster = Dust::LocalVariableDuster.new(LocalVariableBadness, :lvar_shadowed)
- duster.dust!
- duster.warnings.should == [Dust::Warnings::ShadowedVariable.new(:x)]
+ nitpicker = Nitpick::LocalVariableNitpicker.new(LocalVariableBadness, :lvar_shadowed)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == [Nitpick::Warnings::ShadowedVariable.new(:x)]
end
it "should warn when a block variable (among many) shadows a local variable" do
- duster = Dust::LocalVariableDuster.new(LocalVariableBadness, :lvar_shadowed_many_block_vars)
- duster.dust!
- duster.warnings.should == [Dust::Warnings::ShadowedVariable.new]
+ nitpicker = Nitpick::LocalVariableNitpicker.new(LocalVariableBadness, :lvar_shadowed_many_block_vars)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == [Nitpick::Warnings::ShadowedVariable.new]
end
it "should not warn when a block variable does not shadow a local variable" do
- duster = Dust::LocalVariableDuster.new(LocalVariableBadness, :lvar_not_shadowed)
- duster.dust!
- duster.warnings.should == []
+ nitpicker = Nitpick::LocalVariableNitpicker.new(LocalVariableBadness, :lvar_not_shadowed)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == []
end
it "should not warn when a block arg is referenced" do
- duster = Dust::LocalVariableDuster.new(LocalVariableBadness, :block_arg_curried)
- duster.dust!
- duster.warnings.should == []
+ nitpicker = Nitpick::LocalVariableNitpicker.new(LocalVariableBadness, :block_arg_curried)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == []
end
it "should not warn when splat args are used with splats" do
- duster = Dust::LocalVariableDuster.new(LocalVariableBadness, :splat_args_used_with_splat)
- duster.dust!
- duster.warnings.should == []
+ nitpicker = Nitpick::LocalVariableNitpicker.new(LocalVariableBadness, :splat_args_used_with_splat)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == []
end
it "should not warn about unused args" do
- duster = Dust::LocalVariableDuster.new(LocalVariableBadness, :simple_unused_arg)
- duster.dust!
- duster.warnings.should == []
+ nitpicker = Nitpick::LocalVariableNitpicker.new(LocalVariableBadness, :simple_unused_arg)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == []
end
it "shouldn't barf on anonymous splat args" do
- duster = Dust::LocalVariableDuster.new(LocalVariableBadness, :anonymous_args)
- duster.dust!
- duster.warnings.should == []
+ nitpicker = Nitpick::LocalVariableNitpicker.new(LocalVariableBadness, :anonymous_args)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == []
end
end
View
14 spec/method_nitpicker_spec.rb
@@ -3,16 +3,16 @@
include Fixtures
-describe Dust::MethodDuster do
+describe Nitpick::MethodNitpicker do
it "should create a warning for an empty method" do
- duster = Dust::MethodDuster.new(MethodBadness, :empty_method)
- duster.dust!
- duster.warnings.include?(Dust::Warnings::EmptyMethod.new(:empty_method)).should be_true
+ nitpicker = Nitpick::MethodNitpicker.new(MethodBadness, :empty_method)
+ nitpicker.nitpick!
+ nitpicker.warnings.include?(Nitpick::Warnings::EmptyMethod.new(:empty_method)).should be_true
end
it "should not create a empty method warning for a non empty method" do
- duster = Dust::MethodDuster.new(MethodBadness, :non_empty_method)
- duster.dust!
- duster.warnings.any? {|w| w.is_a? Dust::Warnings::EmptyMethod }.should be_false
+ nitpicker = Nitpick::MethodNitpicker.new(MethodBadness, :non_empty_method)
+ nitpicker.nitpick!
+ nitpicker.warnings.any? {|w| w.is_a? Nitpick::Warnings::EmptyMethod }.should be_false
end
end
View
8 spec/nitpicker_spec.rb
@@ -3,18 +3,18 @@
include Fixtures
-describe Dust::Duster do
+describe Nitpick::Nitpicker do
before do
- @duster = duster = Dust::Duster.new(BranchBadness, :branch_returning_true_or_false)
+ @nitpicker = nitpicker = Nitpick::Nitpicker.new(BranchBadness, :branch_returning_true_or_false)
end
it "should discover each of the warning classes with the correct options" do
- warnings = [Dust::Warnings::UselessBranch, Dust::Warnings::IdenticalBranch]
+ warnings = [Nitpick::Warnings::UselessBranch, Nitpick::Warnings::IdenticalBranch]
branches = [s(:true), s(:false)]
warnings.each do |warning|
warning.should_receive(:discover).with(branches)
end
- @duster.scan_for warnings, :with => branches
+ @nitpicker.scan_for warnings, :with => branches
end
end
View
20 spec/rescue_nitpicker_spec.rb
@@ -3,23 +3,23 @@
include Fixtures
-describe Dust::RescueDuster do
+describe Nitpick::RescueNitpicker do
it "should create a warning for rescuing to a value" do
- duster = Dust::RescueDuster.new(RescueBadness, :rescue_nil)
- duster.dust!
- duster.warnings.should == [Dust::Warnings::RescueValue.new]
+ nitpicker = Nitpick::RescueNitpicker.new(RescueBadness, :rescue_nil)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == [Nitpick::Warnings::RescueValue.new]
end
it "should create a warning for rescuing Exception" do
- duster = Dust::RescueDuster.new(RescueBadness, :rescue_exception)
- duster.dust!
- duster.warnings.should == [Dust::Warnings::RescueEverything.new]
+ nitpicker = Nitpick::RescueNitpicker.new(RescueBadness, :rescue_exception)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == [Nitpick::Warnings::RescueEverything.new]
end
it "should create a warning for rescuing Object" do
- duster = Dust::RescueDuster.new(RescueBadness, :rescue_object)
- duster.dust!
- duster.warnings.should == [Dust::Warnings::RescueEverything.new]
+ nitpicker = Nitpick::RescueNitpicker.new(RescueBadness, :rescue_object)
+ nitpicker.nitpick!
+ nitpicker.warnings.should == [Nitpick::Warnings::RescueEverything.new]
end
end
View
8 spec/rescue_value_spec.rb
@@ -3,15 +3,15 @@
include Fixtures
-describe Dust::Warnings::RescueValue do
+describe Nitpick::Warnings::RescueValue do
it "should match rescuing to a nil" do
- warning = Dust::Warnings::RescueValue.new(nil, [:nil])
+ warning = Nitpick::Warnings::RescueValue.new(nil, [:nil])
warning.matches?.should be_true
end
it "should match rescuing to a lit" do
- warning = Dust::Warnings::RescueValue.new(nil, [:lit, 4])
+ warning = Nitpick::Warnings::RescueValue.new(nil, [:lit, 4])
warning.matches?.should be_true
end
@@ -21,7 +21,7 @@
[:call, [:lit, 4], :+, [:array, [:lit, 5]]],
[:call, [:lit, 6], :+, [:array, [:lit, 7]]]]]
- warning = Dust::Warnings::RescueValue.new(*exp)
+ warning = Nitpick::Warnings::RescueValue.new(*exp)
warning.matches?.should be_false
end
end
View
18 spec/shadowed_variable_spec.rb
@@ -3,25 +3,25 @@
include Fixtures
-describe Dust::Warnings::ShadowedVariable do
+describe Nitpick::Warnings::ShadowedVariable do
it "should match an lasgn" do
- warning = Dust::Warnings::ShadowedVariable.new(s(:lasgn, :x, nil))
+ warning = Nitpick::Warnings::ShadowedVariable.new(s(:lasgn, :x, nil))
warning.matches?.should be_true
end
it "should not match when there are no assignments" do
- warning = Dust::Warnings::ShadowedVariable.new(nil)
+ warning = Nitpick::Warnings::ShadowedVariable.new(nil)
warning.matches?.should_not be_true
end
it "should not match a block variable assignment" do
- warning = Dust::Warnings::ShadowedVariable.new(s(:dasgn_curr, :y))
+ warning = Nitpick::Warnings::ShadowedVariable.new(s(:dasgn_curr, :y))
warning.matches?.should_not be_true
end
it "should store the name of a shadowed variable" do
- warning = Dust::Warnings::ShadowedVariable.new(s(:lasgn, :x, nil))
+ warning = Nitpick::Warnings::ShadowedVariable.new(s(:lasgn, :x, nil))
warning.matches?
warning.vars.should == Set.new([:x])
end
@@ -30,21 +30,21 @@
exp = s(:masgn, s(:array, s(:dasgn_curr, :p), s(:dasgn_curr, :d),
s(:dasgn_curr, :q), s(:lasgn, :x, nil)), nil, nil)
- warning = Dust::Warnings::ShadowedVariable.new(exp)
+ warning = Nitpick::Warnings::ShadowedVariable.new(exp)
warning.matches?.should be_true
warning.vars.should == Set.new([:x])
end
it "should handle splat args in multiple assignment" do
exp = s(:masgn, s(:array, s(:dasgn_curr, :x), s(:dasgn_curr, :y)), s(:lasgn, :a), nil)
- warning = Dust::Warnings::ShadowedVariable.new(exp)
+ warning = Nitpick::Warnings::ShadowedVariable.new(exp)
warning.matches?.should be_true
warning.vars.should == Set.new([:a])
end
it "should handle one splat arg" do
exp = s(:masgn, nil, s(:lasgn, :a), nil)
- warning = Dust::Warnings::ShadowedVariable.new(exp)
+ warning = Nitpick::Warnings::ShadowedVariable.new(exp)
warning.matches?.should be_true
warning.vars.should == Set.new([:a])
end
@@ -52,7 +52,7 @@
it "should store the name of all shadowed variables" do
exp = s(:masgn, s(:array, s(:dasgn_curr, :p), s(:dasgn_curr, :d),
s(:lasgn, :q, nil), s(:lasgn, :x, nil)), nil, nil)
- warning = Dust::Warnings::ShadowedVariable.new(exp)
+ warning = Nitpick::Warnings::ShadowedVariable.new(exp)
warning.matches?
warning.vars.should == Set.new([:q, :x])
end
View
10 spec/simple_warning_spec.rb
@@ -3,20 +3,20 @@
include Fixtures
-describe Dust::Warnings::SimpleWarning do
+describe Nitpick::Warnings::SimpleWarning do
it "should discover a matching warning" do
branch = mock("aUselessBranch")
branch.should_receive(:matches?).and_return(true)
- Dust::Warnings::UselessBranch.stub!(:new).and_return(branch)
+ Nitpick::Warnings::UselessBranch.stub!(:new).and_return(branch)
- Dust::Warnings::UselessBranch.discover.should == branch
+ Nitpick::Warnings::UselessBranch.discover.should == branch
end
it "should not discover a non-matching warning" do
branch = mock("aUselessBranch")
branch.should_receive(:matches?).and_return(false)
- Dust::Warnings::UselessBranch.stub!(:new).and_return(branch)
+ Nitpick::Warnings::UselessBranch.stub!(:new).and_return(branch)
- Dust::Warnings::UselessBranch.discover.should be_nil
+ Nitpick::Warnings::UselessBranch.discover.should be_nil
end
end
View
2  spec/spec_helper.rb
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), *%w[.. lib dust])
+require File.join(File.dirname(__FILE__), *%w[.. lib nitpick])
$:.unshift File.dirname(__FILE__)
require 'spec'
View
4 spec/useless_branch_spec.rb
@@ -3,9 +3,9 @@
include Fixtures
-describe Dust::Warnings::UselessBranch do
+describe Nitpick::Warnings::UselessBranch do
it "should match against branches returning only true and false" do
- warning = Dust::Warnings::UselessBranch.new(s(:cond), s(:true), s(:false))
+ warning = Nitpick::Warnings::UselessBranch.new(s(:cond), s(:true), s(:false))
warning.matches?.should be_true
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.