#30 ✓resolved
Kevin Rutherford

provide matchers for rspec

Reported by Kevin Rutherford | March 26th, 2009 @ 09:10 AM

Provide one or matchers for rspec, so that users can write examples such as this:


"def simple?() true; end".should_not smell
"def x() y + z; end".should smell_of(:UncommunicativeName, /x/)
File("example.rb").should_not smell

There's also the possibility of something such as


Dir["lib/**/*.rb"].should smell_of(:FeatureEnvy)

which may require some notion of a multi-report.

Comments and changes to this ticket

  • Kevin Rutherford

    Kevin Rutherford March 26th, 2009 @ 09:11 AM

    • State changed from “new” to “open”
  • Kevin Rutherford

    Kevin Rutherford March 26th, 2009 @ 09:44 AM

    Code such as

    
    "def x() y + z; end".should smell_of(:UncommunicativeName, /x/)
    

    would check that the report contained an instance of UncommunicativeName, and that it's warning message matched /x/.

    The names are camel case because FeatureEnvy, for example, is the name of a class of smell :)

  • Kevin Rutherford

    Kevin Rutherford March 26th, 2009 @ 09:49 AM

    So I envisage usages such as this:

    
    it 'should recognise different bad names' do
      code = "def x(z) y + z; end"
      code.should smell_of(:UncommunicativeName, /x/, /method/)
      code.should smell_of(:UncommunicativeName, /y/, /variable/)
      code.should smell_of(:UncommunicativeName, /z/, /parameter/)
    end
    

    (This will allow me to rewrite most of Reek's own examples; I don't expect general users to make much use of it.)

  • Kevin Rutherford

    Kevin Rutherford March 29th, 2009 @ 08:56 AM

    Peeled off the Dir part into #32, because it requires a bit of a rethink about design of reports and such.

  • Kevin Rutherford

    Kevin Rutherford March 29th, 2009 @ 10:14 AM

    • State changed from “open” to “resolved”

    Resolved at tag v0.3.1.3, except for Dir matchers (see #32).

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Defects and feature requests for <a href="http://wiki.github.com/kevinrutherford/reek">Reek</a>, the Ruby code smell detector

People watching this ticket

Pages