import org.sonar.api.batch.SensorContext;
import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.resources.Project;
-import org.sonar.api.utils.Logs;
public class CheckstyleSensor implements Sensor {
* @deprecated in 2.8, because assumes that Sonar executed from Maven. Not used any more in sonar-cobertura-plugin.
* See http://jira.codehaus.org/browse/SONAR-2321
*/
+ @Deprecated
public static File getReport(Project project) {
File report = getReportFromProperty(project);
if (report == null) {
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.math.NumberUtils;
import org.sonar.api.batch.*;
import org.sonar.api.database.model.RuleFailureModel;
import org.sonar.api.database.model.SnapshotSource;
return violationMap;
}
- private final boolean isNotAlreadyMapped(Violation newViolation, Map<Violation, RuleFailureModel> violationMap) {
+ private boolean isNotAlreadyMapped(Violation newViolation, Map<Violation, RuleFailureModel> violationMap) {
return violationMap.get(newViolation) == null;
}
}
private boolean isSameLine(Violation newViolation, RuleFailureModel pastViolation) {
- return pastViolation.getLine() == newViolation.getLineId(); //When lines are null, we also return true
+ if (pastViolation.getLine()==null && newViolation.getLineId()==null) {
+ return true;
+ }
+ return ObjectUtils.equals(pastViolation.getLine(), newViolation.getLineId());
}
private boolean isSameMessage(Violation newViolation, RuleFailureModel pastViolation) {
*/
package org.sonar.plugins.findbugs;
-import org.apache.commons.lang.StringUtils;
import org.sonar.api.CoreProperties;
import org.sonar.api.batch.Sensor;
import org.sonar.api.batch.SensorContext;
*/
package org.sonar.plugins.pmd;
-import java.io.File;
-
import org.sonar.api.batch.Sensor;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.resources.Project;
import org.sonar.api.rules.RuleFinder;
-import org.sonar.api.utils.Logs;
import org.sonar.api.utils.XmlParserException;
+import java.io.File;
+
public class PmdSensor implements Sensor {
private RulesProfile profile;
import org.sonar.check.Priority;
import org.sonar.check.Rule;
-import org.sonar.check.RuleProperty;
import org.sonar.squid.api.CheckMessage;
-import org.sonar.squid.api.SourceClass;
import org.sonar.squid.api.SourceFile;
import org.sonar.squid.measures.Metric;
@Override
public void visitFile(SourceFile file) {
int loc = file.getInt(Metric.LINES_OF_CODE);
- if (loc==0) {
+ if (loc == 0) {
CheckMessage message = new CheckMessage(this, "This Java file is empty");
file.log(message);
}
*/
package org.sonar.plugins.surefire;
-import org.sonar.api.*;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.SonarPlugin;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
}
return false;
} catch (StackOverflowError e) {
- throw new RuntimeException(
+ throw new IllegalArgumentException(
"The regular expression "
+ regex
+ " has led to a stack overflow error. "
try {
if (code.getColumnPosition() == 0 && listElement.consume(code, output)) {
while (endOfLine.consume(code, output) && listElement.consume(code, output)) {
+ // consume input
}
output.append("</ul>");
return true;
@Override
protected void consume(CharSequence token, MarkdownOutput output) {
- if ( !pendingListConstruction) {
+ if (!pendingListConstruction) {
output.append("<ul>");
pendingListConstruction = true;
}
}
}
- private class EndOfLine extends RegexChannel<MarkdownOutput> {
+ private static final class EndOfLine extends RegexChannel<MarkdownOutput> {
public EndOfLine() {
super("(\r?\n)|(\r)");
*/
package org.sonar.markdown;
-import java.util.ArrayList;
-import java.util.List;
-
import org.sonar.channel.Channel;
import org.sonar.channel.ChannelDispatcher;
import org.sonar.channel.CodeReader;
+import java.util.Arrays;
+import java.util.List;
+
/**
* Entry point of the Markdown library
*/
-public class MarkdownEngine {
+public final class MarkdownEngine {
- private MarkdownOutput output;
private ChannelDispatcher<MarkdownOutput> dispatcher;
private MarkdownEngine() {
- output = new MarkdownOutput();
- List<Channel> markdownChannels = new ArrayList<Channel>();
- markdownChannels.add(new HtmlUrlChannel());
- markdownChannels.add(new HtmlEndOfLineChannel());
- markdownChannels.add(new HtmlEmphasisChannel());
- markdownChannels.add(new HtmlListChannel());
- markdownChannels.add(new HtmlCodeChannel());
- markdownChannels.add(new IdentifierAndNumberChannel());
- markdownChannels.add(new BlackholeChannel());
+ List<Channel> markdownChannels = Arrays.<Channel>asList(
+ new HtmlUrlChannel(),
+ new HtmlEndOfLineChannel(),
+ new HtmlEmphasisChannel(),
+ new HtmlListChannel(),
+ new HtmlCodeChannel(),
+ new IdentifierAndNumberChannel(),
+ new BlackholeChannel());
dispatcher = new ChannelDispatcher<MarkdownOutput>(markdownChannels);
}
+ private String convert(String input) {
+ CodeReader reader = new CodeReader(input);
+ try {
+ MarkdownOutput output = new MarkdownOutput();
+ dispatcher.consume(reader, output);
+ return output.toString();
+
+ } finally {
+ reader.close();
+ }
+ }
+
public static String convertToHtml(String input) {
- MarkdownEngine engine = new MarkdownEngine();
- engine.dispatcher.consume(new CodeReader(input), engine.output);
- return engine.output.toString();
+ return new MarkdownEngine().convert(input);
}
}
* @since 1.10
* @deprecated in 2.8. Use {@link SonarPlugin} instead.
*/
+@Deprecated
public interface Plugin {
/**
* the request parameters specified as a {@link ViolationQuery}
* @return the list of violations that match those parameters
*/
- public abstract List<Violation> getViolations(ViolationQuery violationQuery);
+ abstract List<Violation> getViolations(ViolationQuery violationQuery);
/**
* Returns all the active (= non switched-off) violations found on the current resource.
import com.google.gwt.i18n.client.Dictionary;
+/**
+ * @deprecated since 2.8. Use sonar-gwt-api instead.
+ */
+@Deprecated
public final class ResourceDictionary {
public final static String CONF_PERMALINK_BASE = "permalink_url_base";
* A class of web utility
*
* @since 1.10
+ * @deprecated since 2.8. Use sonar-gwt-api instead.
*/
+@Deprecated
public final class Utils {
private Utils() {
}
import org.sonar.api.web.gwt.client.Utils;
import org.sonar.api.web.gwt.client.widgets.LoadingLabel;
+/**
+ * @deprecated since 2.8. Use sonar-gwt-api instead.
+ */
+@Deprecated
public abstract class BaseQueryCallback<P extends ResponsePOJO> implements QueryCallBack<P> {
private LoadingLabel loading;
import com.google.gwt.core.client.JavaScriptObject;
+/**
+ * @deprecated since 2.8. Use sonar-gwt-api instead.
+ */
+@Deprecated
public abstract class JSONHandlerDispatcher<P extends ResponsePOJO> implements JsonUtils.JSONHandler {
private QueryCallBack<P> callBack;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
+/**
+ * @deprecated since 2.8. Use sonar-gwt-api instead.
+ */
+@Deprecated
public final class JsonUtils {
private static int requestId = 0;
*/
package org.sonar.api.web.gwt.client.webservices;
+/**
+ * @deprecated since 2.8. Use sonar-gwt-api instead.
+ */
+@Deprecated
public abstract class Query<R extends ResponsePOJO> {
public abstract void execute(final QueryCallBack<R> callback);
import com.google.gwt.core.client.JavaScriptObject;
+/**
+ * @deprecated since 2.8. Use sonar-gwt-api instead.
+ */
+@Deprecated
public interface QueryCallBack<RESPONSE_POJO extends ResponsePOJO> {
void onResponse(RESPONSE_POJO response, JavaScriptObject jsonRawResponse);
/**
* Marker class for WS query response objects
*/
+/**
+ * @deprecated since 2.8. Use sonar-gwt-api instead.
+ */
+@Deprecated
public abstract class ResponsePOJO {
}
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.user.client.Timer;
+/**
+ * @deprecated since 2.8. Use sonar-gwt-api instead.
+ */
+@Deprecated
public class SequentialQueries extends Query<VoidResponse> {
private List<AjaxQuery<?>> queries = new ArrayList<AjaxQuery<?>>();
*/
package org.sonar.api.web.gwt.client.webservices;
+/**
+ * @deprecated since 2.8. Use sonar-gwt-api instead.
+ */
+@Deprecated
public class VoidResponse extends ResponsePOJO {
}
import java.util.ArrayList;
import java.util.List;
+/**
+ * @deprecated since 2.8. Use sonar-gwt-api instead.
+ */
+@Deprecated
public final class WSMetrics {
private WSMetrics() {
package org.sonar.server.database;
-import org.hibernate.HibernateException;
import org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider;
import javax.sql.DataSource;
static DataSource datasource;
@Override
- public void configure(Properties props) throws HibernateException {
+ public void configure(Properties props) {
setDataSource(datasource);
super.configure(props);
}
import org.apache.commons.dbcp.BasicDataSourceFactory;
import org.apache.commons.lang.StringUtils;
import org.hibernate.cfg.Environment;
-import org.sonar.api.CoreProperties;
import org.sonar.api.database.DatabaseProperties;
import org.sonar.api.utils.Logs;
import org.sonar.api.utils.SonarException;
try {
Context envCtx = (Context) ctx.lookup(JNDI_ENV_CONTEXT);
- datasource = (DataSource)envCtx.lookup(jndiKey);
+ datasource = (DataSource) envCtx.lookup(jndiKey);
Logs.INFO.info("JDBC datasource loaded from JNDI: " + jndiKey);
} catch (NamingException e) {
}
datasource = BasicDataSourceFactory.createDataSource(properties);
- CustomHibernateConnectionProvider.datasource=datasource;
+ CustomHibernateConnectionProvider.datasource = datasource;
} catch (Exception e) {
throw new SonarException("Fail to connect to database", e);
}
* @param id
* the id to set
*/
- public void setId(Long id) {
+ public Review setId(Long id) {
this.id = id;
+ return this;
}
/**
* @param createdAt
* the createdAt to set
*/
- public void setCreatedAt(Date createdAt) {
+ public Review setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
+ return this;
}
/**
* @param updatedAt
* the updatedAt to set
*/
- public void setUpdatedAt(Date updatedAt) {
+ public Review setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
+ return this;
}
/**
}
/**
- * @param authorLogin
+ * @param s
* the authorLogin to set
*/
- public void setAuthorLogin(String authorLogin) {
- this.authorLogin = authorLogin;
+ public Review setAuthorLogin(String s) {
+ this.authorLogin = s;
+ return this;
}
/**
}
/**
- * @param assigneeLogin
+ * @param s
* the assigneeLogin to set
*/
- public void setAssigneeLogin(String assigneeLogin) {
- this.assigneeLogin = assigneeLogin;
+ public Review setAssigneeLogin(String s) {
+ this.assigneeLogin = s;
+ return this;
}
/**
}
/**
- * @param title
+ * @param s
* the title to set
*/
- public void setTitle(String title) {
- this.title = title;
+ public Review setTitle(String s) {
+ this.title = s;
+ return this;
}
/**
}
/**
- * @param type
+ * @param s
* the type to set
*/
- public void setType(String type) {
- this.type = type;
+ public Review setType(String s) {
+ this.type = s;
+ return this;
}
/**
* @param status
* the status to set
*/
- public void setStatus(String status) {
+ public Review setStatus(String status) {
this.status = status;
+ return this;
}
/**
* @param severity
* the severity to set
*/
- public void setSeverity(String severity) {
+ public Review setSeverity(String severity) {
this.severity = severity;
+ return this;
}
/**
* @param resourceKee
* the resourceKee to set
*/
- public void setResourceKee(String resourceKee) {
+ public Review setResourceKee(String resourceKee) {
this.resourceKee = resourceKee;
+ return this;
}
/**
* @param line
* the line to set
*/
- public void setLine(Integer line) {
+ public Review setLine(Integer line) {
this.line = line;
+ return this;
}
/**
return comments;
}
- /**
- * @param comments
- * the comments to set
- */
- public void addComments(Date updatedAt, String authorLogin, String text) {
+ public Review addComments(Date updatedAt, String authorLogin, String text) {
this.comments.add(new Review.Comment(updatedAt, authorLogin, text));
+ return this;
}
/**
* @since 2.8
*/
- public class Comment extends Model {
+ public static final class Comment extends Model {
private String authorLogin = null;
private Date updatedAt = null;