Uploaded image for project: 'Product Roadmaps'
  1. Product Roadmaps
  2. MMF-2344

Use Eclipse Compiler warnings to improve the precision of Java rules

    XMLWordPrintable

    Details

    • Type: MMF
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Labels:
      None

      Description

      WHY

      We are currently using Eclipse frontend to generate the AST and get the semantic. This approach helps us to design and implement nice rules with good precision.
      In addition to the parsing, ECJ also generates compiler warnings. Some of these warnings are actually targeting the same problems as the ones we report in our rules.
      The aim is to use the warnings provided by the compiler to reduce the complexity and improve the precision of our rules.

      WHAT

      For many rules, the precision of our implementation is in fact already as good if not better than the warnings. The idea is therefore to use the warnings only when there are real benefits, to improve the precision or reduce the maintenance cost for example.
      For this MMF, we identified 4 rules that could benefit from this:

      • RSPEC-1128: UselessImportCheck
      • RSPEC-1905: RedundantTypeCastCheck
        These two rules have been subject to many FN and FP in the past, this leads to a complex implementation still not perfect, that could be greatly simplified thanks to the warnings.
      • RSPEC-4970: UnreachableCatchCheck
        Since the first implementation of this rule, we had to reduce the scope in order to avoid false positives. The ECJ warnings are doing better than our current version.
      • RSPEC-1656: SelfAssignementCheck
        The current implementation is based on syntactic equivalence, while ECJ uses semantic. This rule precision could be greatly improved.

      HOW

      During the parsing, we have access to the list of compiler "Problems" for free. We are in fact already using some of them, to report incomplete semantic warnings in the logs. We can collect the warnings of interest and make them accessible from the Java checks. This will allow us to use them directly in the checks, and either directly report an issue, or use them to improve the precision of our results.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              michael.gumowski Michael Gumowski
              Reporter:
              richard.mathis Richard Mathis
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: