credo icon indicating copy to clipboard operation
credo copied to clipboard

Existing software design suggestions are not ignored on diff

Open mcrumm opened this issue 3 years ago • 4 comments

Environment

  • Credo version (mix credo -v): 1.6.2
  • Erlang/Elixir version (elixir -v): 1.12.0
  • Operating system: MacOS

What were you trying to do?

First, thanks for all the hard work on this library!

I am introducing Credo on an existing codebase and I am trying to get a reasonable CI setup in place. The new diff options looked like exactly what I want, in that I'd like to only fail for issues that are new to the branch under test. I ran the following on a branch with no changes:

mix credo diff --from-git-ref origin/main

Expected outcome

All existing issues are marked fixed/kept. No existing issues are marked added. Exits with code 0.

Actual outcome


Changes between origin/main and working dir:

+  added 29 new software design suggestions,
✔  fixed 5 consistency issues, 9 warnings, 126 refactoring opportunities, 1355 code readability issues, 33 software design suggestions, and
~  kept 5 consistency issues, 9 warnings, 126 refactoring opportunities, 1355 code readability issues, 4 software design suggestions.

Use `mix credo explain` to explain issues, `mix credo diff --help` for options.

Exits with code 2.

mcrumm avatar Jan 24 '22 21:01 mcrumm

The new diff options looked like exactly what I want, in that I'd like to only fail for issues that are new to the branch under test.

This sounds like you want to use --from-git-merge-base? Could be wrong though.

--from-git-ref works like git diff in that it compares the current state of origin/main with your branch.

--from-git-merge-base compares only the parts that changed on your branch, since you branched it off of origin/main.

rrrene avatar Jan 25 '22 10:01 rrrene

Hi @rrrene, thanks for the reply! The output is the same regardless of which git diff flag I use. :) It's a little odd since design seems to be the only category afflicted.

mcrumm avatar Jan 25 '22 14:01 mcrumm

Mmmm, sounds strange. Do you know of any open source repos where you have this problem? Repos where we can reproduce this, that is.

rrrene avatar Jan 26 '22 21:01 rrrene

At the moment, no :( But on second glance, the problem appears to be isolated to duplicate code suggestions.

I will see if I can make a sample project to reproduce :)

mcrumm avatar Jan 27 '22 01:01 mcrumm

I apologize for the age/inactivity on this issue. I should have done a better job at resolving this properly. 😥

Please feel free to re-open this issue at your discretion, especially if this is still a problem with Credo's current version.

rrrene avatar Feb 03 '23 21:02 rrrene