From 1473d21796fc48121a7b15a9fb01a19eec1b7ddb Mon Sep 17 00:00:00 2001 From: Pranav Gaikwad Date: Mon, 8 Jul 2024 16:10:27 -0400 Subject: [PATCH] :ghost: Revert "Revert ":bug: Be able to process FIELD rules"" (#644) Reverts konveyor/analyzer-lsp#639 --- demo-output.yaml | 13 +++++++++++++ .../pkg/java_external_provider/provider.go | 1 + .../pkg/java_external_provider/service_client.go | 2 ++ rule-example.yaml | 10 +++++++++- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/demo-output.yaml b/demo-output.yaml index 1a8090dc..fd1953b9 100644 --- a/demo-output.yaml +++ b/demo-output.yaml @@ -899,6 +899,19 @@ matchingXML: "" effort: 1 insights: + field-rule-00001: + description: Sample field declaration rule + category: mandatory + incidents: + - uri: file:///examples/customers-tomcat-legacy/src/main/java/io/konveyor/demo/ordermanagement/service/CustomerService.java + message: Field found + codeSnip: " 8 import org.springframework.data.domain.Page;\n 9 import org.springframework.data.domain.Pageable;\n10 import org.springframework.stereotype.Service;\n11 import org.springframework.transaction.annotation.Transactional;\n12 \n13 @Service\n14 @Transactional\n15 public class CustomerService implements ICustomerService{\n16 \t\n17 \t@Autowired\n18 \tprivate CustomerRepository repository;\n19 \t\n20 \tprivate static Logger logger = Logger.getLogger( CustomerService.class.getName() );\n21 \t\n22 \tpublic Customer findById(Long id) {\n23 \t\tlogger.debug(\"Entering CustomerService.findById()\");\n24 \t\tCustomer c = repository.findById(id).orElse(null);\n25 \t\tlogger.debug(\"Returning element: \" + c);\n26 \t\treturn c;\n27 \t}\n28 \t" + lineNumber: 18 + variables: + file: file:///examples/customers-tomcat-legacy/src/main/java/io/konveyor/demo/ordermanagement/service/CustomerService.java + kind: Field + name: repository + package: io.konveyor.demo.ordermanagement.service java-downloaded-maven-artifact: description: | This rule tests the application downloaded from maven artifact diff --git a/external-providers/java-external-provider/pkg/java_external_provider/provider.go b/external-providers/java-external-provider/pkg/java_external_provider/provider.go index e329a63a..93ba3529 100644 --- a/external-providers/java-external-provider/pkg/java_external_provider/provider.go +++ b/external-providers/java-external-provider/pkg/java_external_provider/provider.go @@ -58,6 +58,7 @@ var locationToCode = map[string]int{ "variable_declaration": 9, "type": 10, "package": 11, + "field": 12, } type javaProvider struct { diff --git a/external-providers/java-external-provider/pkg/java_external_provider/service_client.go b/external-providers/java-external-provider/pkg/java_external_provider/service_client.go index ccb83704..f59ed947 100644 --- a/external-providers/java-external-provider/pkg/java_external_provider/service_client.go +++ b/external-providers/java-external-provider/pkg/java_external_provider/service_client.go @@ -80,6 +80,8 @@ func (p *javaServiceClient) Evaluate(ctx context.Context, cap string, conditionI incidents, err = p.filterDefault(symbols) case 11: incidents, err = p.filterDefault(symbols) + case 12: + incidents, err = p.filterDefault(symbols) default: } diff --git a/rule-example.yaml b/rule-example.yaml index 67bfb04c..542f0234 100644 --- a/rule-example.yaml +++ b/rule-example.yaml @@ -329,4 +329,12 @@ ruleID: java-downloaded-maven-artifact when: java.referenced: - pattern: io.javaoperatorsdk.operator.Operator \ No newline at end of file + pattern: io.javaoperatorsdk.operator.Operator +- category: mandatory + description: Sample field declaration rule + message: "Field found" + ruleID: field-rule-00001 + when: + java.referenced: + pattern: io.konveyor.demo.ordermanagement.repository.CustomerRepository + location: FIELD