Class RemoveCommentedCodeCodemod

java.lang.Object
io.codemodder.javaparser.JavaParserChanger
io.codemodder.providers.sonar.SonarPluginJavaParserChanger<com.github.javaparser.ast.comments.Comment,io.codemodder.sonar.model.Issue>
io.codemodder.codemods.RemoveCommentedCodeCodemod
All Implemented Interfaces:
io.codemodder.CodeChanger, io.codemodder.FixOnlyCodeChanger

@Codemod(id="sonar:java/remove-commented-code-s125", reviewGuidance=MERGE_WITHOUT_REVIEW, importance=HIGH, executionPriority=HIGH) public final class RemoveCommentedCodeCodemod extends io.codemodder.providers.sonar.SonarPluginJavaParserChanger<com.github.javaparser.ast.comments.Comment,io.codemodder.sonar.model.Issue>
A codemod for removing commented-out lines of code. This codemod has dubious value because Sonar often reports a single line out of many consecutive lines that may have code, so removing that particular line will only result in a half-removed commented, which is potentially more confusing. It also false positives when comments start with common coding tokens.
  • Field Summary

    Fields inherited from class io.codemodder.providers.sonar.SonarPluginJavaParserChanger

    ruleFinding

    Fields inherited from class io.codemodder.javaparser.JavaParserChanger

    reporter
  • Constructor Summary

    Constructors
    Constructor
    Description
    RemoveCommentedCodeCodemod(io.codemodder.providers.sonar.RuleIssue issues)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    io.codemodder.codetf.DetectorRule
     
    io.codemodder.javaparser.ChangesResult
    onFindingFound(io.codemodder.CodemodInvocationContext context, com.github.javaparser.ast.CompilationUnit cu, com.github.javaparser.ast.comments.Comment comment, io.codemodder.sonar.model.Issue issue)
     

    Methods inherited from class io.codemodder.providers.sonar.SonarPluginJavaParserChanger

    shouldRun, vendorName, visit

    Methods inherited from class io.codemodder.javaparser.JavaParserChanger

    getDescription, getIndividualChangeDescription, getReferences, getSummary

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RemoveCommentedCodeCodemod

      @Inject public RemoveCommentedCodeCodemod(@ProvidedSonarScan(ruleId="java:S125") io.codemodder.providers.sonar.RuleIssue issues)
  • Method Details

    • onFindingFound

      public io.codemodder.javaparser.ChangesResult onFindingFound(io.codemodder.CodemodInvocationContext context, com.github.javaparser.ast.CompilationUnit cu, com.github.javaparser.ast.comments.Comment comment, io.codemodder.sonar.model.Issue issue)
      Specified by:
      onFindingFound in class io.codemodder.providers.sonar.SonarPluginJavaParserChanger<com.github.javaparser.ast.comments.Comment,io.codemodder.sonar.model.Issue>
    • detectorRule

      public io.codemodder.codetf.DetectorRule detectorRule()