use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class AbstractDbTester method pkOf.
@CheckForNull
private PK pkOf(Connection connection, String tableName) throws SQLException {
try (ResultSet resultSet = connection.getMetaData().getPrimaryKeys(null, null, tableName)) {
String pkName = null;
ArrayList<String> columnNames = null;
while (resultSet.next()) {
if (columnNames == null) {
pkName = resultSet.getString("PK_NAME");
columnNames = new ArrayList<>(1);
} else {
assertThat(pkName).as("Multiple primary keys found").isEqualTo(resultSet.getString("PK_NAME"));
}
columnNames.add(resultSet.getInt("KEY_SEQ") - 1, resultSet.getString("COLUMN_NAME"));
}
if (columnNames == null) {
return null;
}
return new PK(pkName, columnNames);
}
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class AbstractDbTester method getColumnIndex.
@CheckForNull
private Integer getColumnIndex(ResultSet res, String column) {
try {
ResultSetMetaData meta = res.getMetaData();
int numCol = meta.getColumnCount();
for (int i = 1; i < numCol + 1; i++) {
if (meta.getColumnLabel(i).toLowerCase().equals(column.toLowerCase())) {
return i;
}
}
return null;
} catch (Exception e) {
throw new IllegalStateException("Fail to get column index");
}
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class AppFileSystemTest method getFileKey.
@CheckForNull
private static Object getFileKey(File fileInTempDir) throws IOException {
Path path = Paths.get(fileInTempDir.toURI());
BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class);
return attrs.fileKey();
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class FilterParser method tryParsingCriterionNotHavingValues.
@CheckForNull
private static Criterion tryParsingCriterionNotHavingValues(String criterion) {
Matcher matcher = PATTERN.matcher(criterion);
if (!matcher.find()) {
return null;
}
Criterion.Builder builder = new Criterion.Builder();
builder.setKey(matcher.group(1));
String operatorValue = matcher.group(2);
String value = matcher.group(3);
if (!isNullOrEmpty(operatorValue) && !isNullOrEmpty(value)) {
builder.setOperator(Operator.getByValue(operatorValue));
builder.setValue(sanitizeValue(value));
}
return builder.build();
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class CommonRule method processFile.
@CheckForNull
public DefaultIssue processFile(Component file, String fileLanguage) {
DefaultIssue issue = null;
RuleKey ruleKey = RuleKey.of(commonRepositoryForLang(fileLanguage), key);
Optional<ActiveRule> activeRule = activeRulesHolder.get(ruleKey);
if (activeRule.isPresent()) {
CommonRuleIssue cri = doProcessFile(file, activeRule.get());
if (cri != null) {
issue = new DefaultIssue();
issue.setGap(cri.effortToFix);
issue.setMessage(cri.message);
issue.setRuleKey(ruleKey);
issue.setSeverity(activeRule.get().getSeverity());
issue.setLine(null);
issue.setChecksum("");
}
}
return issue;
}
Aggregations