-
-
Notifications
You must be signed in to change notification settings - Fork 521
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
Sq 8 2+azure devops #202
Sq 8 2+azure devops #202
Changes from all commits
fb5af34
2c99abf
8ac7e97
77b5e9c
0a34144
f203253
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package com.github.mc1arke.sonarqube.plugin.ce.pullrequest.azuredevops.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.github.mc1arke.sonarqube.plugin.ce.pullrequest.azuredevops.model.enums.CommentType; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
|
||
/** | ||
* Represents a comment which is one of potentially many in a comment thread. | ||
*/ | ||
public class Comment implements Serializable { | ||
|
||
private String content; | ||
private CommentType commentType; | ||
private Integer parentCommentId; | ||
private int id; | ||
private int threadId; | ||
private IdentityRef author; | ||
private Date publishedDate; | ||
private Date lastUpdatedDate; | ||
private Date lastContentUpdatedDate; | ||
@JsonProperty("isDeleted") | ||
private Boolean deleted; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
private List<IdentityRef> usersLiked; | ||
@JsonProperty("_links") | ||
private ReferenceLinks links; | ||
|
||
public Comment() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As with other classes, can you confirm where this constructor is used, as I'd like the fields in this to be final if possible? |
||
} | ||
|
||
public Comment(String content) { | ||
this.content = content; | ||
this.parentCommentId = 0; | ||
this.commentType = CommentType.TEXT; | ||
} | ||
|
||
/** | ||
* The ID of the parent comment. This is used for replies. | ||
*/ | ||
public Integer getParentCommentId() { | ||
return this.parentCommentId; | ||
} | ||
/** | ||
* The comment content. | ||
*/ | ||
public String getContent() { | ||
return this.content; | ||
} | ||
/** | ||
* The comment type at the time of creation. | ||
*/ | ||
public CommentType getCommentType() { | ||
return this.commentType; | ||
} | ||
/** | ||
* The comment ID. IDs start at 1 and are unique to a pull request. | ||
*/ | ||
public int getId() { | ||
return this.id; | ||
} | ||
/** | ||
* The parent thread ID. Used for internal server purposes only -- note | ||
* that this field is not exposed to the REST client. | ||
*/ | ||
public int getThreadId() { | ||
return this.threadId; | ||
} | ||
/** | ||
* The author of the comment. | ||
*/ | ||
public IdentityRef getAuthor() { | ||
return this.author; | ||
} | ||
/** | ||
* The date the comment was first published.; | ||
*/ | ||
public Date getPublishedDate() { | ||
return this.publishedDate; | ||
} | ||
/** | ||
* The date the comment was last updated. | ||
*/ | ||
public Date getLastUpdatedDate() { | ||
return this.lastUpdatedDate; | ||
} | ||
/** | ||
* The date the comment's content was last updated. | ||
*/ | ||
public Date getLastContentUpdatedDate() { | ||
return this.lastContentUpdatedDate; | ||
} | ||
/** | ||
* Whether or not this comment was soft-deleted. | ||
*/ | ||
public Boolean isDeleted() { | ||
return this.deleted; | ||
} | ||
/** | ||
* A list of the users who have liked this comment. | ||
*/ | ||
public List<IdentityRef> getUsersLiked() { | ||
return this.usersLiked; | ||
} | ||
/** | ||
* Links to other related objects. | ||
*/ | ||
public ReferenceLinks getLinks() { | ||
return this.links; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.github.mc1arke.sonarqube.plugin.ce.pullrequest.azuredevops.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.io.Serializable; | ||
|
||
public class CommentPosition implements Serializable { | ||
private final int line; | ||
private final int offset; | ||
|
||
@JsonCreator | ||
public CommentPosition(@JsonProperty("line") int line, @JsonProperty("offset") int offset){ | ||
this.line = line; | ||
this.offset = offset + 1; | ||
} | ||
/** | ||
*The line number of a thread's position. Starts at 1. /// | ||
*/ | ||
public int getLine() | ||
{ | ||
return this.line; | ||
}; | ||
|
||
/** | ||
*The character offset of a thread's position inside of a line. Starts at 0. | ||
*/ | ||
public int getOffset(){ | ||
return this.offset; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package com.github.mc1arke.sonarqube.plugin.ce.pullrequest.azuredevops.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.github.mc1arke.sonarqube.plugin.ce.pullrequest.azuredevops.model.enums.CommentThreadStatus; | ||
import org.sonar.db.protobuf.DbIssues; | ||
|
||
import java.io.Serializable; | ||
import java.util.Arrays; | ||
import java.util.Date; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
/** | ||
* Represents a comment thread of a pull request. A thread contains meta data about the file | ||
* it was left on along with one or more comments (an initial comment and the subsequent replies). | ||
*/ | ||
public class CommentThread implements Serializable { | ||
|
||
private CommentThreadStatus status; | ||
private List<Comment> comments; | ||
private CommentThreadContext threadContext; | ||
private int id; | ||
private Date publishedDate; | ||
private Date lastUpdatedDate; | ||
private HashMap<String, IdentityRef> identities; | ||
@JsonProperty("isDeleted") | ||
private Boolean deleted; | ||
@JsonProperty("_links") | ||
private ReferenceLinks links; | ||
public CommentThread(){}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is this constructor used? In theory, all the fields above it should be final, but this constructor prevents that. |
||
|
||
public CommentThread(String filePath, DbIssues.Locations locations, String message){ | ||
comments = Arrays.asList( | ||
new Comment(message) | ||
); | ||
status = CommentThreadStatus.ACTIVE; //CommentThreadStatusMapper.toCommentThreadStatus(issue.status()); | ||
threadContext = new CommentThreadContext( | ||
filePath, | ||
locations | ||
); | ||
|
||
} | ||
/** | ||
* A list of the comments. | ||
*/ | ||
public List<Comment> getComments(){ | ||
return this.comments; | ||
}; | ||
/** | ||
* The status of the comment thread. | ||
*/ | ||
public CommentThreadStatus getStatus(){ | ||
return this.status; | ||
}; | ||
/** | ||
* Specify thread context such as position in left/right file. | ||
*/ | ||
public CommentThreadContext getThreadContext() { | ||
return this.threadContext; | ||
}; | ||
/** | ||
* The comment thread id. | ||
*/ | ||
public int getId() | ||
{ | ||
return this.id; | ||
}; | ||
/** | ||
* The time this thread was published. | ||
*/ | ||
public Date getPublishedDate() | ||
{ | ||
return this.publishedDate; | ||
}; | ||
/** | ||
* The time this thread was last updated. | ||
*/ | ||
public Date getLastUpdatedDate() | ||
{ | ||
return this.lastUpdatedDate; | ||
}; | ||
/** | ||
* Set of identities related to this thread | ||
*/ | ||
public HashMap<String, IdentityRef> getIdentities() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we narrow this down to a |
||
{ | ||
return this.identities; | ||
}; | ||
/** | ||
* Specify if the thread is deleted which happens when all comments are deleted. | ||
*/ | ||
public Boolean isDeleted() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this actually nullable, or can it be a |
||
{ | ||
return this.deleted; | ||
}; | ||
/** | ||
* Links to other related objects. | ||
*/ | ||
public ReferenceLinks getLinks() | ||
{ | ||
return this.links; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.github.mc1arke.sonarqube.plugin.ce.pullrequest.azuredevops.model; | ||
|
||
import org.sonar.db.protobuf.DbIssues; | ||
|
||
import java.io.Serializable; | ||
|
||
public class CommentThreadContext implements Serializable { | ||
|
||
private String filePath; | ||
private CommentPosition leftFileStart; | ||
private CommentPosition leftFileEnd; | ||
private CommentPosition rightFileStart; | ||
private CommentPosition rightFileEnd; | ||
|
||
public CommentThreadContext() {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, is this constructor actually required? I generally aim for the classes to be immutable but this constructor prevents the fields in this class from being declared final |
||
|
||
public CommentThreadContext(String filePath, DbIssues.Locations locations){ | ||
this.filePath = filePath; | ||
this.leftFileEnd = null; | ||
this.leftFileStart = null; | ||
this.rightFileEnd = new CommentPosition( | ||
locations.getTextRange().getEndLine(), | ||
locations.getTextRange().getEndOffset() | ||
); | ||
this.rightFileStart = new CommentPosition( | ||
locations.getTextRange().getStartLine(), | ||
locations.getTextRange().getStartOffset() | ||
); | ||
} | ||
/** | ||
* File path relative to the root of the repository. It's up to the client to | ||
*/ | ||
public String getFilePath(){ | ||
return this.filePath; | ||
}; | ||
/** | ||
* Position of first character of the thread's span in left file. /// | ||
*/ | ||
public CommentPosition getLeftFileStart(){ | ||
return this.leftFileStart; | ||
}; | ||
/** | ||
* Position of last character of the thread's span in left file. /// | ||
*/ | ||
public CommentPosition getLeftFileEnd(){ | ||
return this.leftFileEnd; | ||
}; | ||
/** | ||
* Position of first character of the thread's span in right file. /// | ||
*/ | ||
public CommentPosition getRightFileStart(){ | ||
return this.rightFileStart; | ||
}; | ||
/** | ||
* Position of last character of the thread's span in right file. /// | ||
*/ | ||
public CommentPosition getRightFileEnd(){ | ||
return this.rightFileEnd; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.github.mc1arke.sonarqube.plugin.ce.pullrequest.azuredevops.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public class CommentThreadResponse { | ||
private final CommentThread[] value; | ||
|
||
@JsonCreator | ||
public CommentThreadResponse(@JsonProperty("value") CommentThread[] value){ | ||
this.value = value; | ||
} | ||
public CommentThread[] getValue(){ | ||
return this.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.
This only seems to have been introduced to allow logging of all the properties, which doesn't seem like a good use case. The logging should either happen in the PostAnalysisTask that triggers decoration, or be removed.