void verifyNoGplChange()

in lib/src/license_detection/confidence.dart [217:257]


void verifyNoGplChange(Iterable<Diff> diffs, String identifier) {
  var prevText = '';
  var prevDelete = '';

  for (var diff in diffs) {
    final text = diff.text;

    switch (diff.operation) {
      case Operation.insert:

        // Ignores substitution of "library" with "lesser" in gnu license,
        // but looks for other additions of "lesser" that would lead to
        // a mismatch.
        if (text == 'lesser' &&
            prevText.endsWith('gnu') &&
            prevDelete != 'library') {
          if (!prevText.contains('warranty')) {
            throw LicenseMismatchException(
                'License does not match with $identifier due to lesser GPL change');
          }
        }
        break;

      case Operation.delete:
        if (text == 'lesser' && prevText.endsWith('gnu')) {
          if (!prevText.contains('warranty')) {
            throw LicenseMismatchException(
                'License does not match with $identifier due to lesser GPL change');
          }
        }

        prevDelete = text;
        break;

      case Operation.equal:
        prevText = text;
        prevDelete = '';
        break;
    }
  }
}