This repository has been archived by the owner. It is now read-only.

Mention method name in argument_amount report. #172

Merged
merged 1 commit into from Jun 8, 2016

Conversation

Projects
None yet
2 participants
@mvidner
Copy link
Contributor

mvidner commented Jun 7, 2016

Other analysis classes name the language element they report on but ArgumentAmount did not.

Before:

test.rb: error: line 14, column 1: wrong number of arguments (expected 0 but got 1)

After:

test.rb: error: line 14, column 1: wrong number of arguments for 'greet' (expected 0 but got 1)

I have also considered to distinguish class and instance methods but opted for simplicity.

... for '#greet' ...
... for '.greet' ...

@mvidner

This comment has been minimized.

Copy link
Contributor

mvidner commented Jun 7, 2016

Another way to improve this would be qualifying the method with the class/module it is defined in, but I didn't see an obvious way to determine that.

Yet another way to address this would be omitting the names from the report but quoting the source, clang style:

test.rb:14:9:error: wrong number of arguments (expected 0 but got 1)
    user.greet(:foo)
         ^^^^^^^^^^
@YorickPeterse

This comment has been minimized.

Copy link
Owner

YorickPeterse commented Jun 7, 2016

Another way to improve this would be qualifying the method with the class/module it is defined in, but I didn't see an obvious way to determine that.

In theory this should be possible using the scope variable, but it may be a tad tricky to get the fully qualified name.

Yet another way to address this would be omitting the names from the report but quoting the source, clang style:

A separate reporter class could probably do this by reading the file (present in an entry), getting the line (also present) and then displaying it below the message.


second.line.should == 7
second.column.should == 1
second.message.should == 'wrong number of arguments (expected 1 but got 2)'
second.message.should == 'wrong number of arguments for \'initialize\' ' \

This comment has been minimized.

@YorickPeterse

YorickPeterse Jun 7, 2016

Owner

For these tests we can just use double quotes, this removes the need for escaping the single quotes.

Mention method name in argument_amount report.
Before:
    test.rb: error: line 14, column 1: wrong number of arguments (expected 0 but got 1)
After:
    test.rb: error: line 14, column 1: wrong number of arguments for 'greet' (expected 0 but got 1)

@mvidner mvidner force-pushed the mvidner:method-name-in-argument-amount branch from 5a92993 to 02742aa Jun 8, 2016

@YorickPeterse YorickPeterse merged commit 826f4b0 into YorickPeterse:master Jun 8, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@YorickPeterse

This comment has been minimized.

Copy link
Owner

YorickPeterse commented Jun 8, 2016

Thanks!

@mvidner mvidner deleted the mvidner:method-name-in-argument-amount branch Jun 8, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.