Skip to content

encoded-compare: fix suggestions for JSONEq and YAMLEq #248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ccoVeille
Copy link
Contributor

I spotted it by using the following code:

var foo json.RawMessage
assert.EqualValues(t, `{"foo": "bar"}`, foo)

that testifylint suggested fixing like this:

var foo json.RawMessage
assert.JSONEq(t, `{"foo": "bar"}`, foo)

It's invalid because JSONEq expects strings.

Later, I noticed the code was also suggesting to replace (even if it's invalid):

var i int
assert.Equal(t, `{"foo": "bar"}`, i)

with:

var i int
assert.JSONEq(t, `{"foo": "bar"}`, i)

The PR is divided in 2 commits to help to reproduce the issue:

  • encoded-compare: add tests to reveal false positives
  • encoded-compare: fix suggestions for JSONEq and YAMLEq

I spotted it by using the following code:

    var foo json.RawMessage
    assert.EqualValues(t, `{"foo": "bar"}`, foo)

that testifylint suggested fixing like this:

    var foo json.RawMessage
    assert.JSONEq(t, `{"foo": "bar"}`, foo)

It's invalid because JSONEq expects strings.

Later, I noticed the code was also suggesting to replace:

    assert.Equal(t, `{"foo": "bar"}`, 42)

with:

    assert.JSONEq(t, `{"foo": "bar"}`, 42)
@coveralls
Copy link

Pull Request Test Coverage Report for Build 15742930669

Details

  • 31 of 31 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 93.65%

Totals Coverage Status
Change from base Build 14796134649: 0.02%
Covered Lines: 2625
Relevant Lines: 2803

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants