Skip to content

Commit

Permalink
Making CodeNarc respect source directory
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Jan 9, 2019
1 parent bb58987 commit f2b46f0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
out
.classpath
.project
.settings
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@

Changelog of Violations git lib.

## Unreleased
### No issue

**Making CodeNarc respect source directory**


[c42152470d8016d](https://github.com/tomasbjerre/violations-git-lib/commit/c42152470d8016d) Tomas Bjerre *2019-01-09 18:32:01*


## 1.15
### No issue

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ apply from: project.buildscript.classLoader.getResource('release.gradle').toURI(


dependencies {
compile 'se.bjurr.violations:violations-lib:1.68'
compile 'se.bjurr.violations:violations-lib:1.77'
compile 'org.eclipse.jgit:org.eclipse.jgit:4.9.2.201712150930-r'
compile 'com.jakewharton.fliptables:fliptables:1.0.2'

Expand Down
10 changes: 4 additions & 6 deletions src/main/java/se/bjurr/violations/git/PatchParser.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package se.bjurr.violations.git;

import static se.bjurr.violations.lib.util.Optional.absent;

import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import se.bjurr.violations.lib.util.Optional;

public class PatchParser {

/** http://en.wikipedia.org/wiki/Diff_utility#Unified_format */
public static Optional<Integer> findLineInDiff(
final String patchString, final Integer lineToComment) {
if (patchString == null) {
return Optional.absent();
return Optional.empty();
}
int currentLine = -1;
int patchLocation = 0;
Expand All @@ -30,12 +28,12 @@ public static Optional<Integer> findLineInDiff(
} else if (line.startsWith("+") || line.startsWith(" ")) {
// Added or unmodified
if (currentLine == lineToComment) {
return Optional.fromNullable(patchLocation);
return Optional.ofNullable(patchLocation);
}
currentLine++;
}
patchLocation++;
}
return absent();
return Optional.empty();
}
}
2 changes: 1 addition & 1 deletion src/main/java/se/bjurr/violations/git/ViolationsGit.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import se.bjurr.violations.git.data.DiffsPerFile;
import se.bjurr.violations.lib.model.Violation;
import se.bjurr.violations.lib.util.Optional;

public class ViolationsGit {
private final List<Violation> violations;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/se/bjurr/violations/git/data/DiffsPerFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import java.util.Map;
import java.util.Map.Entry;
import se.bjurr.violations.lib.util.Optional;
import java.util.Optional;

public class DiffsPerFile {

Expand All @@ -27,6 +27,6 @@ public Optional<String> findPatchString(final String file) {
}
}
}
return Optional.fromNullable(patchString);
return Optional.ofNullable(patchString);
}
}

0 comments on commit f2b46f0

Please sign in to comment.