@@ -23,7 +23,6 @@ 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.utils.Logs; | |||
public class CheckstyleSensor implements Sensor { | |||
@@ -39,6 +39,7 @@ public final class CoberturaUtils { | |||
* @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) { |
@@ -23,7 +23,9 @@ import com.google.common.collect.LinkedHashMultimap; | |||
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; | |||
@@ -123,7 +125,7 @@ public class ViolationPersisterDecorator implements Decorator { | |||
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; | |||
} | |||
@@ -161,7 +163,10 @@ public class ViolationPersisterDecorator implements Decorator { | |||
} | |||
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) { |
@@ -19,7 +19,6 @@ | |||
*/ | |||
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; |
@@ -19,16 +19,15 @@ | |||
*/ | |||
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; |
@@ -22,9 +22,7 @@ package org.sonar.java.squid.check; | |||
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; | |||
@@ -35,7 +33,7 @@ public final class EmptyFileCheck extends SquidCheck { | |||
@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); | |||
} |
@@ -19,9 +19,11 @@ | |||
*/ | |||
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; | |||
@@ -52,7 +52,7 @@ public abstract class RegexChannel<OUTPUT> extends Channel<OUTPUT> { | |||
} | |||
return false; | |||
} catch (StackOverflowError e) { | |||
throw new RuntimeException( | |||
throw new IllegalArgumentException( | |||
"The regular expression " | |||
+ regex | |||
+ " has led to a stack overflow error. " |
@@ -34,6 +34,7 @@ class HtmlListChannel extends Channel<MarkdownOutput> { | |||
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; | |||
@@ -52,7 +53,7 @@ class HtmlListChannel extends Channel<MarkdownOutput> { | |||
@Override | |||
protected void consume(CharSequence token, MarkdownOutput output) { | |||
if ( !pendingListConstruction) { | |||
if (!pendingListConstruction) { | |||
output.append("<ul>"); | |||
pendingListConstruction = true; | |||
} | |||
@@ -75,7 +76,7 @@ class HtmlListChannel extends Channel<MarkdownOutput> { | |||
} | |||
} | |||
private class EndOfLine extends RegexChannel<MarkdownOutput> { | |||
private static final class EndOfLine extends RegexChannel<MarkdownOutput> { | |||
public EndOfLine() { | |||
super("(\r?\n)|(\r)"); |
@@ -19,37 +19,45 @@ | |||
*/ | |||
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); | |||
} | |||
} |
@@ -31,6 +31,7 @@ import java.util.List; | |||
* @since 1.10 | |||
* @deprecated in 2.8. Use {@link SonarPlugin} instead. | |||
*/ | |||
@Deprecated | |||
public interface Plugin { | |||
/** |
@@ -109,7 +109,7 @@ public interface DecoratorContext { | |||
* 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. |
@@ -21,6 +21,10 @@ package org.sonar.api.web.gwt.client; | |||
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"; |
@@ -32,7 +32,9 @@ import java.util.Set; | |||
* A class of web utility | |||
* | |||
* @since 1.10 | |||
* @deprecated since 2.8. Use sonar-gwt-api instead. | |||
*/ | |||
@Deprecated | |||
public final class Utils { | |||
private Utils() { | |||
} |
@@ -22,6 +22,10 @@ package org.sonar.api.web.gwt.client.webservices; | |||
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; |
@@ -21,6 +21,10 @@ package org.sonar.api.web.gwt.client.webservices; | |||
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; |
@@ -32,6 +32,10 @@ import com.google.gwt.json.client.JSONObject; | |||
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; | |||
@@ -19,6 +19,10 @@ | |||
*/ | |||
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); |
@@ -21,6 +21,10 @@ package org.sonar.api.web.gwt.client.webservices; | |||
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); |
@@ -22,6 +22,10 @@ package org.sonar.api.web.gwt.client.webservices; | |||
/** | |||
* Marker class for WS query response objects | |||
*/ | |||
/** | |||
* @deprecated since 2.8. Use sonar-gwt-api instead. | |||
*/ | |||
@Deprecated | |||
public abstract class ResponsePOJO { | |||
} |
@@ -25,6 +25,10 @@ import java.util.List; | |||
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<?>>(); |
@@ -19,6 +19,10 @@ | |||
*/ | |||
package org.sonar.api.web.gwt.client.webservices; | |||
/** | |||
* @deprecated since 2.8. Use sonar-gwt-api instead. | |||
*/ | |||
@Deprecated | |||
public class VoidResponse extends ResponsePOJO { | |||
} |
@@ -24,6 +24,10 @@ import com.google.gwt.core.client.JavaScriptObject; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
/** | |||
* @deprecated since 2.8. Use sonar-gwt-api instead. | |||
*/ | |||
@Deprecated | |||
public final class WSMetrics { | |||
private WSMetrics() { |
@@ -20,7 +20,6 @@ | |||
package org.sonar.server.database; | |||
import org.hibernate.HibernateException; | |||
import org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider; | |||
import javax.sql.DataSource; | |||
@@ -31,7 +30,7 @@ public class CustomHibernateConnectionProvider extends InjectedDataSourceConnect | |||
static DataSource datasource; | |||
@Override | |||
public void configure(Properties props) throws HibernateException { | |||
public void configure(Properties props) { | |||
setDataSource(datasource); | |||
super.configure(props); | |||
} |
@@ -23,7 +23,6 @@ import org.apache.commons.configuration.Configuration; | |||
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; | |||
@@ -92,7 +91,7 @@ public class JndiDatabaseConnector extends AbstractDatabaseConnector { | |||
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) { | |||
@@ -117,7 +116,7 @@ public class JndiDatabaseConnector extends AbstractDatabaseConnector { | |||
} | |||
datasource = BasicDataSourceFactory.createDataSource(properties); | |||
CustomHibernateConnectionProvider.datasource=datasource; | |||
CustomHibernateConnectionProvider.datasource = datasource; | |||
} catch (Exception e) { | |||
throw new SonarException("Fail to connect to database", e); | |||
} |
@@ -52,8 +52,9 @@ public class Review extends Model { | |||
* @param id | |||
* the id to set | |||
*/ | |||
public void setId(Long id) { | |||
public Review setId(Long id) { | |||
this.id = id; | |||
return this; | |||
} | |||
/** | |||
@@ -67,8 +68,9 @@ public class Review extends Model { | |||
* @param createdAt | |||
* the createdAt to set | |||
*/ | |||
public void setCreatedAt(Date createdAt) { | |||
public Review setCreatedAt(Date createdAt) { | |||
this.createdAt = createdAt; | |||
return this; | |||
} | |||
/** | |||
@@ -82,8 +84,9 @@ public class Review extends Model { | |||
* @param updatedAt | |||
* the updatedAt to set | |||
*/ | |||
public void setUpdatedAt(Date updatedAt) { | |||
public Review setUpdatedAt(Date updatedAt) { | |||
this.updatedAt = updatedAt; | |||
return this; | |||
} | |||
/** | |||
@@ -94,11 +97,12 @@ public class Review extends Model { | |||
} | |||
/** | |||
* @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; | |||
} | |||
/** | |||
@@ -109,11 +113,12 @@ public class Review extends Model { | |||
} | |||
/** | |||
* @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; | |||
} | |||
/** | |||
@@ -124,11 +129,12 @@ public class Review extends Model { | |||
} | |||
/** | |||
* @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; | |||
} | |||
/** | |||
@@ -139,11 +145,12 @@ public class Review extends Model { | |||
} | |||
/** | |||
* @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; | |||
} | |||
/** | |||
@@ -157,8 +164,9 @@ public class Review extends Model { | |||
* @param status | |||
* the status to set | |||
*/ | |||
public void setStatus(String status) { | |||
public Review setStatus(String status) { | |||
this.status = status; | |||
return this; | |||
} | |||
/** | |||
@@ -172,8 +180,9 @@ public class Review extends Model { | |||
* @param severity | |||
* the severity to set | |||
*/ | |||
public void setSeverity(String severity) { | |||
public Review setSeverity(String severity) { | |||
this.severity = severity; | |||
return this; | |||
} | |||
/** | |||
@@ -187,8 +196,9 @@ public class Review extends Model { | |||
* @param resourceKee | |||
* the resourceKee to set | |||
*/ | |||
public void setResourceKee(String resourceKee) { | |||
public Review setResourceKee(String resourceKee) { | |||
this.resourceKee = resourceKee; | |||
return this; | |||
} | |||
/** | |||
@@ -202,8 +212,9 @@ public class Review extends Model { | |||
* @param line | |||
* the line to set | |||
*/ | |||
public void setLine(Integer line) { | |||
public Review setLine(Integer line) { | |||
this.line = line; | |||
return this; | |||
} | |||
/** | |||
@@ -213,18 +224,15 @@ public class Review extends Model { | |||
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; |