-
Notifications
You must be signed in to change notification settings - Fork 81
Upgrade json simple & fix big overview comment issue #118
base: coverage_split_sensor
Are you sure you want to change the base?
Upgrade json simple & fix big overview comment issue #118
Conversation
kingoleg
commented
Mar 27, 2017
- Upgrade json simple
- Cannot post a summary comment. Too many characters. #113
Other word, cannot understand what is a path related to issue - ignore it
…ects with same level parent setup
Can you remove the workingdir/projectbasedir changes from this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general this is useful, I would like the implementation to change a bit though.
And we should define what maxiumum comment sizes to use.
return extractResponse(response); | ||
} catch (ExecutionException | TimeoutException | InterruptedException e) { | ||
throw new StashClientException(e); | ||
} | ||
} | ||
|
||
private static void validateResponse(Response response, int expectedStatusCode, String message) throws StashClientException { | ||
private static void validateResponse(JsonObject body, Response response, int expectedStatusCode, String message) throws StashClientException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about this parameter.
If we keep it it should be named requestBody
.
OTOH it seems weird to pass the body only for logging.
How about removing the exception from validateResponse()
, making it return a bool instead and throwing the exception/logging from performRequest directly
private static final Logger LOGGER = LoggerFactory.getLogger(StashProjectBuilder.class); | ||
|
||
private static final int SOFT_SUMMARY_COMMENT_MAX_LENGTH = 30000; | ||
private static final int HARD_SUMMARY_COMMENT_MAX_LENGTH = Short.MAX_VALUE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did you obtain these values?
@@ -60,6 +67,11 @@ public static String printIssueListBySeverityMarkdown(List<Issue> report, String | |||
for (Map.Entry<String, Issue> rule : rules.entrySet()) { | |||
Issue issue = rule.getValue(); | |||
sb.append("| ").append(printIssueMarkdown(issue, sonarQubeURL)).append(" |").append(NEW_LINE); | |||
if (sb.length() > maxLength) { | |||
sb.append("| ").append(MarkdownPrinter.printSeverityMarkdown(issue.severity())); | |||
sb.append("The rest issues are skipped |").append(NEW_LINE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The rest of the issues have been skipped, because of..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would still allow the message to exceed maxLength
@@ -119,20 +131,30 @@ public static String printReportMarkdown(PullRequestRef pr, String stashURL, Str | |||
sb.append("| Issues list |").append(NEW_LINE); | |||
sb.append("|------------|").append(NEW_LINE); | |||
for (String severity: orderedSeverities) { | |||
sb.append(printIssueListBySeverityMarkdown(generalIssues, sonarQubeURL, severity)); | |||
int maxLength = SOFT_SUMMARY_COMMENT_MAX_LENGTH / 2 - sb.length(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why divide by two?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to have the truncation/maxlength logic in its own wrapper class around StringBuffer.
With the signature:
class SizeSensitiveStringBuffer() {
public SizeSensitiveStringBuffer(int maxLength);
public boolean append(String content, int maxLength, String alternativeContent);
public void append(String content);
}
} | ||
|
||
if (sb.length() > HARD_SUMMARY_COMMENT_MAX_LENGTH) { | ||
LOGGER.debug("Overview comment is too big, trimming"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should be WARN
assertEquals(diff1.getSource(), (long) 10); | ||
assertEquals(diff1.getDestination(),(long) 20); | ||
assertEquals(diff1.getSource(), 10); | ||
assertEquals(diff1.getDestination(),20); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a space missing before the ,
This would be a nice fix to have, on large projects we are getting this error:
|