return min;
}
- private CommonRuleIssue generateIssue(Optional<Measure> commentDensityMeasure, Optional<Measure> commentLinesMeasure, Optional<Measure> nclocMeasure, double minCommentDensity) {
+ private static CommonRuleIssue generateIssue(Optional<Measure> commentDensityMeasure, Optional<Measure> commentLinesMeasure, Optional<Measure> nclocMeasure, double minCommentDensity) {
int commentLines = commentLinesMeasure.isPresent() ? commentLinesMeasure.get().getIntValue() : 0;
int ncloc = nclocMeasure.get().getIntValue();
int minExpectedCommentLines = (int) Math.ceil(minCommentDensity * ncloc / (100 - minCommentDensity));
doFill(request, defaultFields, true);
}
- private void doFill(SearchRequestBuilder request, List<Field> fields, boolean asc) {
+ private static void doFill(SearchRequestBuilder request, List<Field> fields, boolean asc) {
for (Field field : fields) {
FieldSortBuilder sortBuilder = SortBuilders.fieldSort(field.name);
- boolean effectiveAsc = asc ? !field.reverse : field.reverse;
+ boolean effectiveAsc = asc != field.reverse;
sortBuilder.order(effectiveAsc ? SortOrder.ASC : SortOrder.DESC);
- boolean effectiveMissingLast = asc ? field.missingLast : !field.missingLast;
+ boolean effectiveMissingLast = asc == field.missingLast;
sortBuilder.missing(effectiveMissingLast ? "_last" : "_first");
request.addSort(sortBuilder);
}
throw unsupported();
}
- private UnsupportedOperationException unsupported() {
+ private static UnsupportedOperationException unsupported() {
throw new UnsupportedOperationException("See " + ProxyBulkRequestBuilder.class.getName());
}
this.tagAfter = tagAfter;
}
- private boolean hasNextToken(CodeReader code) {
+ private static boolean hasNextToken(CodeReader code) {
int lastChar = code.lastChar();
if (isJavaConstantStart(code.peek()) && !Character.isJavaIdentifierPart(lastChar) && !Character.isJavaIdentifierStart(lastChar)
&& lastChar != DOT) {
throw new IllegalArgumentException(format("Unsupported value for db column ISSUES.ISSUE_TYPE: %d", dbConstant));
}
- public static List<String> ALL_NAMES = Lists.transform(Lists.newArrayList(values()), Enums.stringConverter(IssueType.class).reverse());
+ public static final List<String> ALL_NAMES = Lists.transform(Lists.newArrayList(values()), Enums.stringConverter(IssueType.class).reverse());
}
return Joiner.on(", ").join(descriptions);
}
- private void registerProxyCredentials(Map<String, String> settings) {
+ private static void registerProxyCredentials(Map<String, String> settings) {
Authenticator.setDefault(new ProxyAuthenticator(
settings.get(HTTP_PROXY_USER),
settings.get(HTTP_PROXY_PASSWORD)));
/**
* Trust all certificates
*/
- private SSLSocketFactory createSocketFactory(Ssl context) {
+ private static SSLSocketFactory createSocketFactory(Ssl context) {
try {
return context.newFactory(new AlwaysTrustManager());
} catch (Exception e) {
/**
* Trust all hosts
*/
- private HostnameVerifier createHostnameVerifier() {
+ private static HostnameVerifier createHostnameVerifier() {
return new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
public void test_ALL_NAMES() {
assertThat(IssueType.ALL_NAMES).containsOnly("BUG", "VULNERABILITY", "CODE_SMELL");
}
+
+ @Test
+ public void ALL_NAMES_is_immutable() {
+ expectedException.expect(UnsupportedOperationException.class);
+ IssueType.ALL_NAMES.add("foo");
+ }
}
return mapper(dbSession).countByQuery(query);
}
- private CeActivityMapper mapper(DbSession dbSession) {
+ private static CeActivityMapper mapper(DbSession dbSession) {
return dbSession.getMapper(CeActivityMapper.class);
}
}
return Optional.of(result);
}
- private CeQueueMapper mapper(DbSession session) {
+ private static CeQueueMapper mapper(DbSession session) {
return session.getMapper(CeQueueMapper.class);
}
}
return mapper(session).selectAllowedById(key, userId != null ? userId : -1L);
}
- private DashboardMapper mapper(DbSession session) {
+ private static DashboardMapper mapper(DbSession session) {
return session.getMapper(DashboardMapper.class);
}
}
return mapper(session).selectAll();
}
- private WidgetMapper mapper(DbSession session) {
+ private static WidgetMapper mapper(DbSession session) {
return session.getMapper(WidgetMapper.class);
}
}
}
- private IssueChangeMapper mapper(DbSession session) {
+ private static IssueChangeMapper mapper(DbSession session) {
return session.getMapper(IssueChangeMapper.class);
}
}
mapper(session).update(dto);
}
- private IssueMapper mapper(DbSession session) {
+ private static IssueMapper mapper(DbSession session) {
return session.getMapper(IssueMapper.class);
}
return params;
}
- private PermissionMapper mapper(SqlSession session) {
+ private static PermissionMapper mapper(SqlSession session) {
return session.getMapper(PermissionMapper.class);
}
}
return new Date(system.now());
}
- private PermissionTemplateMapper mapper(SqlSession session) {
+ private static PermissionTemplateMapper mapper(SqlSession session) {
return session.getMapper(PermissionTemplateMapper.class);
}
}
return result;
}
- private Object buildStatementProxy(Class<? extends Statement> stmtClass, InvocationHandler handler) {
+ private static Object buildStatementProxy(Class<? extends Statement> stmtClass, InvocationHandler handler) {
return Proxy.newProxyInstance(ProfilingConnectionHandler.class.getClassLoader(), new Class[] {stmtClass}, handler);
}
return resourceDao.selectWholeTreeForRootId(session, rootId, Scopes.PROJECT);
}
- private PurgeMapper mapper(DbSession session) {
+ private static PurgeMapper mapper(DbSession session) {
return session.getMapper(PurgeMapper.class);
}
}
return selectProjects(query, gateId, 0, Integer.MAX_VALUE);
}
- private ProjectQgateAssociationMapper mapper(SqlSession session) {
+ private static ProjectQgateAssociationMapper mapper(SqlSession session) {
return session.getMapper(ProjectQgateAssociationMapper.class);
}
mapper(session).insert(dto);
}
- private RuleMapper mapper(DbSession session) {
+ private static RuleMapper mapper(DbSession session) {
return session.getMapper(RuleMapper.class);
}
return selectGroups(query, userId, 0, Integer.MAX_VALUE);
}
- private GroupMembershipMapper mapper(SqlSession session) {
+ private static GroupMembershipMapper mapper(SqlSession session) {
return session.getMapper(GroupMembershipMapper.class);
}
}
}
}
- private Table<String, String, String> getProfileKeysByLanguageThenName(final Context context) throws SQLException {
+ private static Table<String, String, String> getProfileKeysByLanguageThenName(final Context context) throws SQLException {
final Table<String, String, String> profilesByLanguageAndName = HashBasedTable.create();
Select selectProfiles = context.prepareSelect("SELECT kee, name, language FROM rules_profiles");
return this;
}
- private String annotatedEngineKey(Object annotatedClassOrObject) {
+ private static String annotatedEngineKey(Object annotatedClassOrObject) {
String key = null;
org.sonar.check.Rule ruleAnnotation = AnnotationUtils.getAnnotation(annotatedClassOrObject, org.sonar.check.Rule.class);
if (ruleAnnotation != null) {
}
@CheckForNull
- private Field getField(Object check, String key) {
+ private static Field getField(Object check, String key) {
List<Field> fields = FieldUtils2.getFields(check.getClass(), true);
for (Field field : fields) {
RuleProperty propertyAnnotation = field.getAnnotation(RuleProperty.class);
return null;
}
- private void configureField(Object check, Field field, String value) {
+ private static void configureField(Object check, Field field, String value) {
try {
field.setAccessible(true);
}
- private void configureField(Object check, Field field, String value) {
+ private static void configureField(Object check, Field field, String value) {
try {
field.setAccessible(true);
}
}
- private Field getField(Object check, String key) {
+ private static Field getField(Object check, String key) {
List<Field> fields = FieldUtils2.getFields(check.getClass(), true);
for (Field field : fields) {
RuleProperty propertyAnnotation = field.getAnnotation(RuleProperty.class);
return null;
}
- private String getRuleKey(Object annotatedClassOrObject) {
+ private static String getRuleKey(Object annotatedClassOrObject) {
String key = null;
Rule ruleAnnotation = AnnotationUtils.getAnnotation(annotatedClassOrObject, Rule.class);
if (ruleAnnotation != null) {
return rule;
}
- private void addRuleProperty(Rule rule, Field field) {
+ private static void addRuleProperty(Rule rule, Field field) {
org.sonar.check.RuleProperty propertyAnnotation = field.getAnnotation(org.sonar.check.RuleProperty.class);
if (propertyAnnotation != null) {
String fieldKey = StringUtils.defaultIfEmpty(propertyAnnotation.key(), field.getName());
} else if (equalsIgnoreCase("internalKey", nodeName)) {
internalKey = nodeValue(cursor);
- } else if (equalsIgnoreCase("priority", nodeName)) {
- // deprecated field, replaced by severity
- severity = nodeValue(cursor);
-
- } else if (equalsIgnoreCase("severity", nodeName)) {
+ } else if (equalsIgnoreCase("priority", nodeName) || equalsIgnoreCase("severity", nodeName)) {
+ // "priority" is deprecated field and has been replaced by "severity"
severity = nodeValue(cursor);
} else if (equalsIgnoreCase("cardinality", nodeName)) {
RuleParamType type = RuleParamType.STRING;
}
- private ParamStruct processParameter(SMInputCursor ruleC) throws XMLStreamException {
+ private static ParamStruct processParameter(SMInputCursor ruleC) throws XMLStreamException {
ParamStruct param = new ParamStruct();
// BACKWARD COMPATIBILITY WITH DEPRECATED FORMAT