Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
}

@Override
public DetectorResult detect(DetectorContext ctx) {

Check warning on line 47 in src/main/java/io/github/randomcodespace/iq/detector/config/GitHubActionsDetector.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

A "Brain Method" was detected. Refactor it to reduce at least one of the following metrics: LOC from 89 to 64, Complexity from 18 to 14, Nesting Level from 3 to 2, Number of Variables from 33 to 6.

See more on https://sonarcloud.io/project/issues?id=RandomCodeSpace_code-iq&issues=AZ1ZhfG8r-X0o8pqO8SP&open=AZ1ZhfG8r-X0o8pqO8SP&pullRequest=40
if (!ctx.filePath().contains(".github/workflows/")) {
return DetectorResult.empty();
}
Expand Down Expand Up @@ -80,7 +80,7 @@
if (onTriggers == null) {
// SnakeYAML may parse bare 'on' key as Boolean.TRUE — search by entry value
onTriggers = data.entrySet().stream()
.filter(e -> Boolean.TRUE.equals(e.getKey()))
.filter(e -> "true".equals(String.valueOf(e.getKey())))
.map(java.util.Map.Entry::getValue)
.findFirst()
.orElse(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ protected DetectorResult detectWithRegex(DetectorContext ctx) {
String path = httpPath != null ? httpPath : "";
String fullPath;
if (finalClassRoute != null) {
fullPath = "/" + finalClassRoute.replaceAll("(^/+|/+$)", "");
fullPath = "/" + finalClassRoute.replaceAll("(^/+)|(/+$)", "");
if (!path.isEmpty()) fullPath = fullPath + "/" + path.replaceAll("^/+", "");
} else {
fullPath = !path.isEmpty() ? "/" + path.replaceAll("^/+", "") : "/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
private static final Pattern GRPC_IMPL_RE = Pattern.compile(
"class\\s+(\\w+)\\s+extends\\s+(\\w+)Grpc\\.(\\w+)ImplBase");
private static final Pattern METHOD_RE = Pattern.compile(
"public\\s+(?:void|[\\w<>\\[\\]]+)\\s+(\\w+)\\s*\\(\\s*(\\w+)");
"public\\s+[\\w<>\\[\\]]+\\s+(\\w+)\\s*\\(\\s*(\\w+)");
private static final Pattern GRPC_STUB_RE = Pattern.compile(
"(\\w+)Grpc\\.new(?:Blocking|Future)?Stub\\s*\\(");

Expand All @@ -48,7 +48,7 @@
}

@Override
public DetectorResult detect(DetectorContext ctx) {

Check warning on line 51 in src/main/java/io/github/randomcodespace/iq/detector/java/GrpcServiceDetector.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

A "Brain Method" was detected. Refactor it to reduce at least one of the following metrics: LOC from 75 to 64, Complexity from 16 to 14, Nesting Level from 5 to 2, Number of Variables from 26 to 6.

See more on https://sonarcloud.io/project/issues?id=RandomCodeSpace_code-iq&issues=AZ1ZhfH-r-X0o8pqO8SR&open=AZ1ZhfH-r-X0o8pqO8SR&pullRequest=40
String text = ctx.content();
if (text == null || text.isEmpty()) return DetectorResult.empty();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@
Type type = var.getType();
if (!type.isClassOrInterfaceType()) continue;
ClassOrInterfaceType cit = type.asClassOrInterfaceType();
if (cit.getTypeArguments().isPresent()) {
var typeArgs = cit.getTypeArguments().get();
var typeArgsOpt = cit.getTypeArguments();
if (typeArgsOpt.isPresent()) {
var typeArgs = typeArgsOpt.get();
if (!typeArgs.isEmpty()) return typeArgs.get(0).asString();
} else {
return cit.getNameAsString();
Expand Down Expand Up @@ -235,7 +236,7 @@

// ==================== Regex fallback ====================

private DetectorResult detectWithRegex(DetectorContext ctx) {

Check warning on line 239 in src/main/java/io/github/randomcodespace/iq/detector/java/JpaEntityDetector.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

A "Brain Method" was detected. Refactor it to reduce at least one of the following metrics: LOC from 85 to 64, Complexity from 19 to 14, Nesting Level from 5 to 2, Number of Variables from 34 to 6.

See more on https://sonarcloud.io/project/issues?id=RandomCodeSpace_code-iq&issues=AZ1ZhfHrr-X0o8pqO8SQ&open=AZ1ZhfHrr-X0o8pqO8SQ&pullRequest=40
String text = ctx.content();
String[] lines = text.split("\n", -1);
List<CodeNode> nodes = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public class RawSqlDetector extends AbstractRegexDetector {

private static final Pattern CLASS_RE = Pattern.compile("(?:public\\s+)?class\\s+(\\w+)");
private static final Pattern QUERY_ANNO_RE = Pattern.compile(
"@Query\\s*\\(\\s*(?:value\\s*=\\s*)?\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"", Pattern.DOTALL);
"@Query\\s*\\(\\s*(?:value\\s*=\\s*)?\"([^\"\\\\]*+(?:\\\\.[^\"\\\\]*+)*+)\"", Pattern.DOTALL);
private static final Pattern NATIVE_QUERY_RE = Pattern.compile("nativeQuery\\s*=\\s*true");
private static final Pattern JDBC_TEMPLATE_RE = Pattern.compile(
"(?:jdbcTemplate|namedParameterJdbcTemplate|JdbcTemplate)\\s*\\."
+ "(?:query|queryForObject|queryForList|queryForMap|update|execute|batchUpdate)"
+ "\\s*\\(\\s*\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"", Pattern.DOTALL);
+ "\\s*\\(\\s*\"([^\"\\\\]*+(?:\\\\.[^\"\\\\]*+)*+)\"", Pattern.DOTALL);
private static final Pattern EM_QUERY_RE = Pattern.compile(
"(?:entityManager|em)\\s*\\.(?:createNativeQuery|createQuery)\\s*\\(\\s*\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"",
"(?:entityManager|em)\\s*\\.(?:createNativeQuery|createQuery)\\s*\\(\\s*\"([^\"\\\\]*+(?:\\\\.[^\"\\\\]*+)*+)\"",
Pattern.DOTALL);
private static final Pattern TABLE_REF_RE = Pattern.compile(
"\\b(?:FROM|JOIN|INTO|UPDATE|TABLE)\\s+(\\w+)", Pattern.CASE_INSENSITIVE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public class NestJSControllerDetector extends AbstractAntlrDetector {
private static final Pattern NESTJS_IMPORT = Pattern.compile("from\\s+['\"]@nestjs/");

private static final Pattern CONTROLLER_PATTERN = Pattern.compile(
"@Controller\\(\\s*['\"`]?([^'\"`\\)\\s]*)['\"`]?\\s*\\)(?:\\s*@\\w+\\([^)]{0,200}\\))*\\s*\\n\\s*(?:export\\s+)?class\\s+(\\w+)"
"@Controller\\(\\s*['\"`]?([^'\"`\\)\\s]*)['\"`]?\\s*\\)(?:\\s*+@\\w+\\([^)]{0,200}\\))*+\\s*\\n\\s*(?:export\\s+)?class\\s+(\\w+)"
);

private static final Pattern ROUTE_PATTERN = Pattern.compile(
"@(Get|Post|Put|Delete|Patch|Options|Head)\\(\\s*['\"`]?([^'\"`\\)\\s]*)['\"`]?\\s*\\)(?:\\s*@\\w+\\([^)]{0,200}\\))*\\s*\\n\\s*(?:async\\s+)?(\\w+)"
"@(Get|Post|Put|Delete|Patch|Options|Head)\\(\\s*['\"`]?([^'\"`\\)\\s]*)['\"`]?\\s*\\)(?:\\s*+@\\w+\\([^)]{0,200}\\))*+\\s*\\n\\s*(?:async\\s+)?(\\w+)"
);

@Override
Expand Down
Loading