How do I use nitpick

I was looking for a program like lint in C and came across nitpick. I
installed the gem but am not sure where to go from there. With lint one
ran it from the command prompt with the file name. I don’t know how
to do this with gems. If I try to run it like lint I get over a dozen
lines of error messages and no output.

On Mon, Sep 28, 2009 at 9:25 PM, Michael W. Ryder
[email protected] wrote:

I was looking for a program like lint in C and came across nitpick. I
installed the gem but am not sure where to go from there. With lint one
ran it from the command prompt with the file name. I don’t know how to do
this with gems. If I try to run it like lint I get over a dozen lines of
error messages and no output.

ripple:~/$ sudo gem install nitpick
Password:
Successfully installed trollop-1.14
Successfully installed nitpick-1.0.2
2 gems installed
Installing ri documentation for trollop-1.14…
Installing ri documentation for nitpick-1.0.2…
Installing RDoc documentation for trollop-1.14…
Installing RDoc documentation for nitpick-1.0.2…
ripple:~/$ which nitpick
/usr/bin/nitpick
ripple:~/$ nitpick --help
Nitpick is a lint-like static code analyzer for Ruby.

Usage: nitpick [(--only str | --except str)*|-h] file1.rb file2.rb

By default, nitpick will analyze all loaded code. To reduce the noise:
–only, -o : Nitpick only classes/modules that match this
string.
–except, -e : Don’t nitpick classes/modules that match this
string.
–help, -h: Show this message
ripple:~/$

Are you sure your installation ran all the way through?

Hassan S. wrote:

Successfully installed trollop-1.14

Usage: nitpick [(--only str | --except str)*|-h] file1.rb file2.rb

By default, nitpick will analyze all loaded code. To reduce the noise:
–only, -o : Nitpick only classes/modules that match this string.
–except, -e : Don’t nitpick classes/modules that match this string.
–help, -h: Show this message
ripple:~/$

Are you sure your installation ran all the way through?

The first time it installed a bunch of dependencies. I just ran it
again and after saying that it was installing RDoc files for nitpick the
following message appeared:
lib/nitpick/sexp_extension.rb:3:23: ‘:’ not followed by identified or
operator
Trying to just use nitpick --help results in a bunch of error messages.
Could this be related to the version of Ruby (1.8.4) or that I am
running this on Windows XP Pro?

On Sep 29, 2009, at 12:00 , Michael W. Ryder wrote:

The first time it installed a bunch of dependencies. I just ran it
again and after saying that it was installing RDoc files for nitpick
the following message appeared:
lib/nitpick/sexp_extension.rb:3:23: ‘:’ not followed by identified
or operator
Trying to just use nitpick --help results in a bunch of error
messages. Could this be related to the version of Ruby (1.8.4) or
that I am running this on Windows XP Pro?

1.8.4?!?

yes. you should update.

I’d like to match a string to another, and recognize the match even if
there are a few typing errors. These errors could include omission of a
letter/space/punctuation mark, an extra letter or a mistyped letter. I
don’t require it to detect multiple errors in a row, or in a single
word. The string would be comparable to the length of this paragraph, a
little shorter, in case that matters

I could come up with some basic implementation for this, but it seems
like a little too much to do for something like this. I was wondering if
there was a simple way to do this, a gem perhaps?

Thanks
-Ehsan

On Tue, Sep 29, 2009 at 5:23 PM, Ehsanul H. [email protected]
wrote:

I’d like to match a string to another, and recognize the match even if there are a few typing errors. These errors could include omission of a letter/space/punctuation mark, an extra letter or a mistyped letter. I don’t require it to detect multiple errors in a row, or in a single word. The string would be comparable to the length of this paragraph, a little shorter, in case that matters

I could come up with some basic implementation for this, but it seems like a little too much to do for something like this. I was wondering if there was a simple way to do this, a gem perhaps?

You could use the Levenshtein distance [1] to check how different is a
string to another. The “Text” [2] gem seems to do that, haven’t used
it though.

[1] http://en.wikipedia.org/wiki/Levenshtein_distance
[2] http://raa.ruby-lang.org/project/levenshtein/

-------- Original-Nachricht --------

Datum: Wed, 30 Sep 2009 05:23:15 +0900
Von: Ehsanul H. [email protected]
An: [email protected]
Betreff: Match a long string in Ruby despite a few typing errors

was a simple way to do this, a gem perhaps?
Dear Ehsan,

you could use Levenstein distance - there’s an implementation in Ruby
here:

http://raa.ruby-lang.org/project/levenshtein/

An even more informative alternative would be using the McIlroy-Hunt
longest common subsequence algorithm, of which you get an implementation
in the diff-lcs gem.

Both algorithms can be implemented with complexity O(m*n), so this
might take some time, if your string lengths m,n are big.

Maybe you can check beforehand that the lengths of string a and b differ
by e.g., 5, so their Levenstein distance is certainly greater than e.g.,
3, which you’d fix as the maximum tolerable error number …

Also, some tweaking allows to bring down the complexity to O(m+n), as is
stated e.g., here : ttp://www.ime.usp.br/~is/papir/sctp/node2.html .

Best regards,

Axel

On Sep 29, 2009, at 13:23 , Ehsanul H. wrote:

wondering if there was a simple way to do this, a gem perhaps?
Don’t thread hijack. Start a new mail like a responsible person.

On Tue, Sep 29, 2009 at 3:23 PM, Ehsanul H. [email protected]
wrote:

I’d like to match a string to another, and recognize the match even if there are a few typing errors. These errors could include omission of a letter/space/punctuation mark, an extra letter or a mistyped letter. I don’t require it to detect multiple errors in a row, or in a single word. The string would be comparable to the length of this paragraph, a little shorter, in case that matters

I could come up with some basic implementation for this, but it seems like a little too much to do for something like this. I was wondering if there was a simple way to do this, a gem perhaps?

Do you know about Soundex?

http://en.wikipedia.org/wiki/Soundex

Looks pretty old but I found this Soundex for Ruby library here:

http://raa.ruby-lang.org/project/soundex/

Ryan D. wrote:

1.8.4?!?

yes. you should update.

I updated to 1.9.1 and now it is complaining that ParseTree does not
work with 1.9.1. Now what do I do?

On Sep 29, 2009, at 18:20 , Michael W. Ryder wrote:

1.8.4?!?
yes. you should update.

I updated to 1.9.1 and now it is complaining that ParseTree does not
work with 1.9.1. Now what do I do?

ParseTree only works up to 1.8.7. ruby_parser will work for 1.9.x, but
it doesn’t work for getting ASTs for procs or other live objects.

Luis, Axel and Greg, I thank you for your suggestions. The levenshtein
distance algorithm seems like the way to go, and I’ll be taking a look
at the implementations mentioned.

I apologize for hijacking the thread. I didn’t realize I was doing this,
I naively assumed threads were based on the subject line, which I
replaced. But apparently not so. It won’t happen again in any case.

1.8.4, but not programs written for 1.8.7 not working for 1.9.1.
Whatever happened to backwards compatibility?

You want the most current of the stable branch, not something off of
what is essentially the development branch. 1.9.1. is a major
refactoring, a work in progress towards the eventual 2.x versions.

Ryan D. wrote:

messages. Could this be related to the version of Ruby (1.8.4)

So my options are:

  1. Downgrade to 1.8.7
  2. Somehow patch ParseTree to work with 1.9 which seems to be a
    f feature request for over a year now.
  3. Patch nitpick to work with ruby_parser
  4. Forget about using any kind of lint program with Ruby.
    Personally I do not like any of the above. I can understand programs
    written for version 1.8.7 not working with 1.8.4, but not programs
    written for 1.8.7 not working for 1.9.1. Whatever happened to backwards
    compatibility?

Hi,

On Sep 29, 2009, at 9:40 PM, Michael W. Ryder wrote:

  1. Somehow patch ParseTree to work with 1.9 which seems to be a
    f feature request for over a year now.

This will not happen with 1.9 in its current state. It’s not a
ParseTree limitation, it’s a Ruby 1.9 limitation.

~ j.

On Sep 29, 2009, at 21:40 , Michael W. Ryder wrote:

So my options are:

  1. Downgrade to 1.8.7

yes, that should work.

  1. Somehow patch ParseTree to work with 1.9 which seems to be a
    f feature request for over a year now.

can’t happen, as john pointed out.

  1. Patch nitpick to work with ruby_parser

this would probably work fine, but I don’t know nitpick so I can only
guess that it is a static-only analysis tool.

  1. Forget about using any kind of lint program with Ruby.

not much gray in your world, is there? :stuck_out_tongue:

Personally I do not like any of the above. I can understand
programs written for version 1.8.7 not working with 1.8.4, but not
programs written for 1.8.7 not working for 1.9.1. Whatever happened
to backwards compatibility?

1.9.x does not (nor did it ever intend to) maintain backwards
compatibility with 1.8. Lots of stuff went in 1.9, that’s what
progress is for.

See also: perl 4 to perl 5, perl 5 to perl 6, deprecations across java
versions, industrial revolution, ponies.

Ryan D. wrote:

can’t happen, as john pointed out.

Personally I do not like any of the above. I can understand

So my best choice is to write my own version of lint using no
dependencies on gems which may be tied to a specific language feature
that may or may not work with the next release of Ruby.

On Wed, Sep 30, 2009 at 11:05 AM, Ryan D. [email protected]
wrote:

On Sep 29, 2009, at 21:40 , Michael W. Ryder wrote:

So my options are:

  1. Downgrade to 1.8.7

yes, that should work.

Is it really a downgrade? Ruby 1.8 and Ruby 1.9 are different
animals. AFAIK lots of people have both installed on their machine.


Paul S.
http://www.nomadicfun.co.uk

[email protected]

On Sep 30, 2009, at 11:50 AM, Michael W. Ryder wrote:

So my best choice is to write my own version of lint using no
dependencies on gems which may be tied to a specific language
feature that may or may not work with the next release of Ruby.

Wow, drama much? I think the best thing for you to do would be to
focus on the specific problem you’re trying to solve (I assume it’s “I
need to lint some code!”) and any specific problems that are keeping
you from doing it right now (maybe, “It’s in 1.9 and nitpick is
jacked!”). Hyperbole is just silly.

Rereading the thread, since nitpick looks to be a static analysis
tool, it seems to me that your “best choice” is to look at modifying
it to use ruby_parser.

~ j.

After using gem install to load
the gem and all the dependencies I found out that my current level of Ruby
was insufficient to run the program. So I updated Ruby to the latest
version

No, you didn’t. You update an older stable version of Ruby for a
cutting edge development release. I don’t think through this whole
thread that you’ve understood that point.

Ruby 1.8.7 is the most up to date stable version.

Ruby 1.9 is a development version, a technology preview, a cutting
edge look at the future of Ruby. It’s not the same as Ruby 1.8, and
it won’t be.


Paul S.
http://www.nomadicfun.co.uk

[email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs