Skip to content

Commit

Permalink
Added branch name in md report
Browse files Browse the repository at this point in the history
  • Loading branch information
Topin2001 committed May 28, 2024
1 parent 8d404c5 commit 0514549
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ private PlaceHolders() {
* Placeholder for project's name
*/
private static final String PROJECTNAME_PLACEHOLDER = "XX-PROJECTNAME-XX";
/**
* Placeholder for the project's branch
*/
private static final String PROJECTBRANCH_PLACEHOLDER = "XX-PROJECTBRANCH-XX";
/**
* Placeholder for the quality gate's anme
*/
Expand Down Expand Up @@ -352,6 +356,9 @@ public static Map<String, String> loadPlaceholdersMap(Report report) {
replacementValues.put(
PROJECTNAME_PLACEHOLDER,
report.getProjectName());
replacementValues.put(
PROJECTBRANCH_PLACEHOLDER,
report.getProjectBranch());
// configuration placeholders
replacementValues.put(
QUALITYGATENAME_PLACEHOLDER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public Report create() throws BadSonarQubeRequestException, UnknownQualityGateEx
report.setProject(projectProvider.getProject(this.project, this.branch));
// project's name's setting
report.setProjectName(report.getProject().getName());
// project's branch's setting
report.setProjectBranch(report.getProject().getBranch());
// formatted issues, unconfirmed issues and raw issues' setting
report.setIssues(issuesProvider.getIssues());
report.setUnconfirmed(issuesProvider.getUnconfirmedIssues());
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/fr/cnes/sonar/report/model/Report.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public class Report {
* Name of the project/report
*/
private String projectName;
/**
* Name of the branch
*/
private String branchName;
/**
* Name of the author
*/
Expand Down Expand Up @@ -107,6 +111,7 @@ public class Report {
*/
public Report() {
this.projectName = "";
this.branchName = "";
this.projectAuthor = "";
this.projectDate = "";
this.qualityProfiles = new ArrayList<>();
Expand Down Expand Up @@ -265,6 +270,24 @@ public void setProjectName(String pProjectName) {
this.projectName = pProjectName;
}

/**
* Getter for branchName
*
* @return branchName
*/
public String getProjectBranch() {
return branchName;
}

/**
* Setter for branchName
*
* @param pBranchName value
*/
public void setProjectBranch(String pBranchName) {
this.branchName = pBranchName;
}

/**
* Getter for projectAuthor
*
Expand Down Expand Up @@ -541,4 +564,5 @@ public Map<String, String> getQualityGateStatus() {
public void setQualityGateStatus(Map<String, String> pQualityGateStatus) {
this.qualityGateStatus = pQualityGateStatus;
}

}
3 changes: 2 additions & 1 deletion src/main/resources/template/code-analysis-template.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Code analysis
## XX-PROJECTNAME-XX
#### Branch XX-PROJECTBRANCH-XX
#### Version XX-VERSION-XX

**By: XX-AUTHOR-XX**
Expand Down Expand Up @@ -82,4 +83,4 @@ $SECURITY_HOTSPOTS_COUNT

### Security hotspots

$SECURITY_HOTSPOTS_DETAILS
$SECURITY_HOTSPOTS_DETAILS

0 comments on commit 0514549

Please sign in to comment.