Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SLCORE-1142 Improve Git blaming for the analysis #1247

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kirill-knize-sonarsource
Copy link
Contributor

@kirill-knize-sonarsource kirill-knize-sonarsource commented Feb 14, 2025

@kirill-knize-sonarsource kirill-knize-sonarsource marked this pull request as draft February 14, 2025 02:20
@kirill-knize-sonarsource kirill-knize-sonarsource force-pushed the feature/kk/git-blame-time-window branch from bd862b3 to c0d21fe Compare February 14, 2025 08:38
@kirill-knize-sonarsource kirill-knize-sonarsource marked this pull request as ready for review February 14, 2025 08:43
Base automatically changed from fix/tha/SLCORE-1133_NativeGit to master February 18, 2025 09:12
@kirill-knize-sonarsource kirill-knize-sonarsource force-pushed the feature/kk/git-blame-time-window branch 2 times, most recently from 94fe8c7 to 9ea9367 Compare February 18, 2025 09:25
@kirill-knize-sonarsource kirill-knize-sonarsource force-pushed the feature/kk/git-blame-time-window branch from 9ea9367 to 625d54b Compare February 18, 2025 10:33
@kirill-knize-sonarsource kirill-knize-sonarsource force-pushed the feature/kk/git-blame-time-window branch 2 times, most recently from 1b25257 to 5c8cf22 Compare February 18, 2025 15:58
@kirill-knize-sonarsource kirill-knize-sonarsource force-pushed the feature/kk/git-blame-time-window branch from 5c8cf22 to f97e0ce Compare February 18, 2025 16:18
Copy link
Contributor

@damien-urruty-sonarsource damien-urruty-sonarsource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments, overall LGTM.
Maybe it would deserve some medium tests to make sure everything is plugged together

@@ -62,6 +62,8 @@ static NewCodeDefinition withNumberOfDaysWithDate(int days, long thresholdDate)
return new NewCodeNumberOfDaysWithDate(days, thresholdDate);
}

long getThresholdDate();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not returning an Instant from here? You can make the conversion later when you use it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think threshold date is maybe not precise enough. I am bad at naming, but what about something like "period start date"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: I would move the method somewhere else, to not be in the middle of with* methods.

@@ -116,6 +118,11 @@ public boolean isSupported() {
return true;
}

@Override
public long getThresholdDate() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this method also be implemented in NewCodeDefinitionWithDate? Maybe it's the case.
EDIT: I see this abstract class is not used at all, maybe we could remove it?

@@ -189,6 +192,11 @@ public static SonarLintBlameResult blameFromNativeCommand(Path projectBaseDir, S
throw new IllegalStateException("There is no native Git available");
}

private static String getBlameHistoryWindow(long thresholdDate) {
var blameLimit = Instant.ofEpochMilli(thresholdDate);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to what I said earlier, we create Instants that we convert to a timestamp, then back to an Instant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants