Skip to content
This repository has been archived by the owner on Sep 19, 2020. It is now read-only.

Fix FC058 false positives #423

Merged
merged 1 commit into from
Feb 22, 2016
Merged

Conversation

jaym
Copy link
Contributor

@jaym jaym commented Feb 17, 2016

There were multiple issues here. First, the test did not
correctly catch this because the wrong match specification
was being created due to line number not being specified.
Instead of defaulting to nil, it defaulted to 1, making
2 incorrect things look correct together.

Second, FC058 needed to check the length of the array
was greater than so, as [] defaults to truthy.

cc @lamont-granquist @tas50 @sersut

Should fix #419

@lamont-granquist
Copy link
Contributor

I suspect that line number defaulting to 1 was intentional and it should be fixed somewhere else up the stack to use 'nil' more explicitly...

@jaym
Copy link
Contributor Author

jaym commented Feb 17, 2016

I thought that as well, however it checks for nil in part of it

@jaym
Copy link
Contributor Author

jaym commented Feb 17, 2016

@jaym
Copy link
Contributor Author

jaym commented Feb 17, 2016

I guess we can push it up the stack based on the order of that merge

@jaym
Copy link
Contributor Author

jaym commented Feb 17, 2016

I actually disagree with that default being there, this is an example of where badness happened because of it

So formal argument for leaving the default as nil:
expect_warning feels weird to have to specify a line for the not case. If you specify a line other than nil and you mess up the line number, you've screwed yourself. If you don't specify a line number, you've once again screwed yourself unless the warning would have been on line 1.

There were multiple issues here. First, the test did not
correctly catch this because the wrong match specification
was being created due to line number not being specified.
Instead of defaulting to nil, it defaulted to 1, making
2 incorrect things look correct together.

Second, FC058 needed to check the length of the arrays
it was getting back was greater than 0, as [] defaults
to truthy.
@jaym jaym force-pushed the jdm/058-false-positives branch from b6ab561 to 3dae2b6 Compare February 17, 2016 21:53
@jaym
Copy link
Contributor Author

jaym commented Feb 17, 2016

After discussion with @lamont-granquist, changing expect_warning to default to nil could drop a lot of cases where the default of 1 was part of the test. Instead, I've added on any line to the match to specify that the line does not matter.

@lamont-granquist
Copy link
Contributor

👍 LGTM @tas50

tas50 added a commit that referenced this pull request Feb 22, 2016
@tas50 tas50 merged commit 6705be0 into Foodcritic:master Feb 22, 2016
@jaym jaym deleted the jdm/058-false-positives branch February 22, 2016 19:23
@nathwill
Copy link

thanks @jaym! can confirm this solved it for me 👍

@tas50 tas50 added the Bug label Jul 3, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FC058: false positive?
4 participants