DaveLiddament / sarb

Static Analysis Results Baseliner
MIT License
162 stars 17 forks source link

False positive: error when using baseline with history on windows #92

Closed XonneX closed 3 years ago

XonneX commented 3 years ago

Hi, I'm using phpcs with sarb on windows and encountered an issue today.

Steps to reproduce:

  1. Create a file with an error
  2. Create baseline
  3. Add some lines (error now on a different line)
  4. Run phpcs and remove errors with sarb

Expected behavior

Still no errors (the history feature works in my pipeline and my docker containers, which run on linux)

Actual behavior

Errors showing, despite being in the baseline

I'm working on a windows machine. Despite that git commands return \n as line breaks. This means that DaveLiddament\StaticAnalysisResultsBaseliner\Domain\HistoryAnalyser\UnifiedDiffParser\Parser on line 62 doesn't work for me. As far as I know git returns \n on all OS and not just linux. I attached the simplest change in a PR. I'm not quite sure if git is outputting somewhere something else than \n, but if we would want to make sure that would work too, the other proposal would be something like this: preg_split("/\r\n|\n|\r/", $diffAsString)

DaveLiddament commented 3 years ago

@XonneX Thanks for raising this issue and also for a really clear example of the problem and for proposing a fix.

I've really busy the past couple of days, but I'll look at this fully in the next day or two and get it merged. Sorry for the delay.

DaveLiddament commented 3 years ago

Fixed and released in 1.0.1. Thanks once again for a clear bug report and a proposed fix. Really appreciate it.

XonneX commented 3 years ago

Thanks for the fast response, merge and release. I appreciate that! 😄