Skip to content

Commit 92c616c

Browse files
committed
Removing not needed fields and added README
1 parent 70b4429 commit 92c616c

File tree

10 files changed

+84
-530
lines changed

10 files changed

+84
-530
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Quboo SonarQube Plugin
2+
3+
# What is Quboo?
4+
5+
[Quboo](https://quboo.io) is a platform that helps you improve your code by using gamification techniques to motivate you and your peers to fix your technical debt.
6+
7+
Go to [quboo.io](https://quboo.io) for more details about how Quboo works and why you should give it a try.
8+
9+
# The plugin
10+
11+
## How does it work?
12+
13+
Our platform uses your code analysis results from SonarQube to extract the game statistics, and also create players based on the existent users in this tool.
14+
15+
This plugin runs after each analysis and collect partial information about your SonarQube users and your existing Issues and send them to Quboo. Then, it computes the new scorecards and badges that you will be able to see next time you access your account via login or public link.
16+
17+
## Installing the Plugin
18+
19+
1. Navigate to [Releases](https://github.com/thepracticaldeveloper/quboo-sonarqube-plugin/releases) and download the latest `.jar` file.
20+
2. Remove any previous version of the plugin and put the new jar in the folder `$SONARQUBE_HOME/extensions/plugins`.
21+
3. Restart your SonarQube server.
22+
23+
## Configuration
24+
25+
After you install the plugin you need Administrator rights to enter your Quboo Access and Secret Keys. The plugin needs these so it can link the data to your account. You can find these values under the section *Settings* when you log in as a user in Quboo.
26+
27+
In SonarQube, you have to enter these keys in the section *Administration -> Configuration -> General Settings -> Quboo (tab)*.
28+
29+
## What information do we send?
30+
31+
We do not need much information for you to play the game, so we collect only some details from Users and Issues. We keep this plugin in an open source repository for transparency so you can see at anytime what is the transferred data:
32+
33+
- **Users**: login, name, active.
34+
- **Issues**: key, rule, severity, componentId, resolution, status, debt, author, creationDate, updateDate, closeDate.
35+
36+
As you can see, **we DO NOT send anything related to code to the server**. Not even your component names, tags, comments, etc.

src/main/java/io/tpd/quboo/sonarplugin/hooks/QubooConnector.java

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
import io.tpd.quboo.sonarplugin.pojos.Users;
1111
import io.tpd.quboo.sonarplugin.settings.QubooProperties;
1212
import okhttp3.*;
13+
import org.apache.commons.lang3.StringUtils;
1314
import org.sonar.api.ce.posttask.PostProjectAnalysisTask;
1415
import org.sonar.api.platform.Server;
1516
import org.sonar.api.utils.log.Logger;
1617
import org.sonar.api.utils.log.Loggers;
1718

19+
import static io.tpd.quboo.sonarplugin.settings.QubooProperties.DEFAULT_ACCESS_KEY;
20+
1821
/**
19-
* Sends stats to the Quboo server after an analysis meeting these conditions:
20-
* 1. On a 'master' branch
21-
* 2. No more than 5 times a day
22-
* 3. Issues created before today
22+
* Sends stats to the Quboo server after an analysis
2323
*/
2424
public class QubooConnector implements PostProjectAnalysisTask {
2525

@@ -38,14 +38,18 @@ public QubooConnector(final Server server) {
3838
public void finished(ProjectAnalysis analysis) {
3939
final String qubooKey = analysis.getScannerContext().getProperties().get(QubooProperties.ACCESS_KEY);
4040
final String qubooSecret = analysis.getScannerContext().getProperties().get(QubooProperties.SECRET_KEY);
41-
log.info("Connecting to Quboo with quboo key: " + qubooKey);
42-
try {
43-
final UsersWrapper allUsers = getUsers();
44-
sendUsersToQuboo(allUsers, qubooKey, qubooSecret);
45-
final IssuesWrapper allIssues = getIssues();
46-
sendIssuesToQuboo(allIssues, qubooKey, qubooSecret);
47-
} catch (final Exception e) {
48-
log.error("Error while trying to connect to Quboo", e);
41+
if (!StringUtils.isEmpty(qubooKey) && !DEFAULT_ACCESS_KEY.equals(qubooKey)) {
42+
log.info("Connecting to Quboo with quboo key: " + qubooKey);
43+
try {
44+
final UsersWrapper allUsers = getUsers();
45+
sendUsersToQuboo(allUsers, qubooKey, qubooSecret);
46+
final IssuesWrapper allIssues = getIssues();
47+
sendIssuesToQuboo(allIssues, qubooKey, qubooSecret);
48+
} catch (final Exception e) {
49+
log.error("Error while trying to connect to Quboo", e);
50+
}
51+
} else {
52+
log.info("Quboo plugin is disabled. Enter your access and secret keys to enable it.");
4953
}
5054
}
5155

@@ -74,7 +78,7 @@ private IssuesWrapper getIssues() throws Exception {
7478
moreData = moreData(issues.getPaging(), issues.getIssues().size());
7579
pageNumber++;
7680
}
77-
log.info("There are " + wrapper.getIssues().size() + " issues");
81+
log.info("Sending " + wrapper.getIssues().size() + " issues to Quboo");
7882
return wrapper;
7983
}
8084

@@ -108,7 +112,7 @@ private UsersWrapper getUsers() {
108112
break;
109113
}
110114
}
111-
log.info("There are " + wrapper.getUsers().size() + " users");
115+
log.info("Sending " + wrapper.getUsers().size() + " users to Quboo");
112116
return wrapper;
113117
}
114118

Lines changed: 4 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
11
package io.tpd.quboo.sonarplugin.pojos;
22

3-
import com.fasterxml.jackson.annotation.*;
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
46
import org.apache.commons.lang3.builder.ToStringBuilder;
57

6-
import java.util.HashMap;
7-
import java.util.Map;
8-
98
@JsonInclude(JsonInclude.Include.NON_NULL)
10-
@JsonPropertyOrder({
11-
"id",
12-
"key",
13-
"uuid",
14-
"enabled",
15-
"qualifier",
16-
"name",
17-
"longName",
18-
"path",
19-
"projectId",
20-
"subProjectId"
21-
})
9+
@JsonIgnoreProperties(ignoreUnknown = true)
2210
public class Component {
2311

2412
@JsonProperty("id")
@@ -29,20 +17,10 @@ public class Component {
2917
private String uuid;
3018
@JsonProperty("enabled")
3119
private Boolean enabled;
32-
@JsonProperty("qualifier")
33-
private String qualifier;
34-
@JsonProperty("name")
35-
private String name;
36-
@JsonProperty("longName")
37-
private String longName;
38-
@JsonProperty("path")
39-
private String path;
4020
@JsonProperty("projectId")
4121
private Integer projectId;
4222
@JsonProperty("subProjectId")
4323
private Integer subProjectId;
44-
@JsonIgnore
45-
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
4624

4725
/**
4826
* @return The id
@@ -128,90 +106,6 @@ public Component withEnabled(Boolean enabled) {
128106
return this;
129107
}
130108

131-
/**
132-
* @return The qualifier
133-
*/
134-
@JsonProperty("qualifier")
135-
public String getQualifier() {
136-
return qualifier;
137-
}
138-
139-
/**
140-
* @param qualifier The qualifier
141-
*/
142-
@JsonProperty("qualifier")
143-
public void setQualifier(String qualifier) {
144-
this.qualifier = qualifier;
145-
}
146-
147-
public Component withQualifier(String qualifier) {
148-
this.qualifier = qualifier;
149-
return this;
150-
}
151-
152-
/**
153-
* @return The name
154-
*/
155-
@JsonProperty("name")
156-
public String getName() {
157-
return name;
158-
}
159-
160-
/**
161-
* @param name The name
162-
*/
163-
@JsonProperty("name")
164-
public void setName(String name) {
165-
this.name = name;
166-
}
167-
168-
public Component withName(String name) {
169-
this.name = name;
170-
return this;
171-
}
172-
173-
/**
174-
* @return The longName
175-
*/
176-
@JsonProperty("longName")
177-
public String getLongName() {
178-
return longName;
179-
}
180-
181-
/**
182-
* @param longName The longName
183-
*/
184-
@JsonProperty("longName")
185-
public void setLongName(String longName) {
186-
this.longName = longName;
187-
}
188-
189-
public Component withLongName(String longName) {
190-
this.longName = longName;
191-
return this;
192-
}
193-
194-
/**
195-
* @return The path
196-
*/
197-
@JsonProperty("path")
198-
public String getPath() {
199-
return path;
200-
}
201-
202-
/**
203-
* @param path The path
204-
*/
205-
@JsonProperty("path")
206-
public void setPath(String path) {
207-
this.path = path;
208-
}
209-
210-
public Component withPath(String path) {
211-
this.path = path;
212-
return this;
213-
}
214-
215109
/**
216110
* @return The projectId
217111
*/
@@ -259,19 +153,4 @@ public String toString() {
259153
return ToStringBuilder.reflectionToString(this);
260154
}
261155

262-
@JsonAnyGetter
263-
public Map<String, Object> getAdditionalProperties() {
264-
return this.additionalProperties;
265-
}
266-
267-
@JsonAnySetter
268-
public void setAdditionalProperty(String name, Object value) {
269-
this.additionalProperties.put(name, value);
270-
}
271-
272-
public Component withAdditionalProperty(String name, Object value) {
273-
this.additionalProperties.put(name, value);
274-
return this;
275-
}
276-
277156
}

0 commit comments

Comments
 (0)