Skip to content

Commit

Permalink
Replace magic number with BLAME_LINE_LENGTH
Browse files Browse the repository at this point in the history
  • Loading branch information
logical-1985516 committed Jul 3, 2024
1 parent 7d7a5a9 commit 23407c0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/reposense/authorship/FileInfoAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class FileInfoAnalyzer {
private static final int AUTHOR_EMAIL_OFFSET = "author-mail ".length();
private static final int AUTHOR_TIME_OFFSET = "author-time ".length();
private static final int AUTHOR_TIMEZONE_OFFSET = "author-tz ".length();
private static final int BLAME_LINE_LENGTH = 5;
private static final int FULL_COMMIT_HASH_LENGTH = 40;

private static final String MESSAGE_FILE_MISSING = "Unable to analyze the file located at \"%s\" "
Expand Down Expand Up @@ -161,7 +162,7 @@ private void aggregateBlameAuthorModifiedAndDateInfo(RepoConfiguration config, F
LocalDateTime sinceDate = config.getSinceDate();
LocalDateTime untilDate = config.getUntilDate();

for (int lineCount = 0; lineCount < blameResultLines.length; lineCount += 5) {
for (int lineCount = 0; lineCount < blameResultLines.length; lineCount += BLAME_LINE_LENGTH) {
String commitHash = blameResultLines[lineCount].substring(0, FULL_COMMIT_HASH_LENGTH);
String authorName = blameResultLines[lineCount + 1].substring(AUTHOR_NAME_OFFSET);
String authorEmail = blameResultLines[lineCount + 2]
Expand All @@ -171,7 +172,7 @@ private void aggregateBlameAuthorModifiedAndDateInfo(RepoConfiguration config, F
config.getZoneId());
Author author = config.getAuthor(authorName, authorEmail);

int lineNumber = lineCount / 5;
int lineNumber = lineCount / BLAME_LINE_LENGTH;
if (!fileInfo.isFileLineTracked(lineNumber) || author.isIgnoringFile(filePath)
|| CommitHash.isInsideCommitList(commitHash, config.getIgnoreCommitList())
|| commitDate.isBefore(sinceDate) || commitDate.isAfter(untilDate)) {
Expand Down

0 comments on commit 23407c0

Please sign in to comment.