wooga / atlas-paket

Paket plugin for gradle
https://wooga.github.io/atlas-paket/
Apache License 2.0
0 stars 2 forks source link

Fix paket.lock file parser #38

Closed Larusso closed 6 years ago

Larusso commented 6 years ago

Description

The paket.lock file parser has issues with counting leading whitespaces. The value from the old logic def newLeadingWhitespaces =(line =~ /\s/).size() returns the number of all white space characters in the current line.

The second part:

if (newLeadingWhitespaces > currentLeadingWhitespaces) {
  currentIndent++
} else if (newLeadingWhitespaces < currentLeadingWhitespaces) {
  currentIndent--
}

didn't take into account when the indention level suddenly jumped from 3 to 1. I also made the method List<String> getAllDependencies(List<String> references) recursive. I added a new test covering the failing behavior

Changes

FIX paket.lock file parsing IMPROVE getAllDependencies method by making it recursive ADD new test example

Larusso commented 6 years ago

I switched from if statements to switch/case because of esthetic reasons. I added some more guards around the switch arms to limit crashes. We might need to add a proper parser with error results if and when we want to support multi type lock files.