Skip to content

Enhance the matching logic to handle: OR, AND #57

@cmoulliard

Description

@cmoulliard

TODO

Enhance the matching logic to handle: OR, AND. Until now, we got from the execution of the maven command to query openrewrite resources a List that we add to the table of the results of a Rule. Unfortunately, we don't handle properly the cases where a user uses part of the query:

condition: query1 OR query2 OR query3 ...
condition: query1 AND query2 AND query3 ...

The existing code should be review to perform what it is described hereafter:

  • Add a new boolean field part of the MigrationTask class to set if match succeeded or failed
  • Return part of the execution of the queries: simple, withOR, withAND a boolean value indication if the match succeeded or not and set the boolean value of the MatchingTask
    Such an information should be added here
        for (Rule rule : rules) {
            Map<String, List<Rewrite>> results = RewriteService.executeRewriteCmd(config, rule); // Return also the match value
            tasks.put(
                    rule.ruleID(),
                    new MigrationTask()
                            .withRule(rule)
                            .withRewriteResults(results.get(rule.ruleID()))
                            .withInstruction(rule.instructions())
            );
        }
  • Use when we display the results: ascii or populate the json the match value of the MatchingTask instead of checking the size of the results.
  • Review the logic of the RewriteService class and method: executeRewriteCmd to handle properly OR, AND

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions