Skip to content

Finding unused classes #36

@lukepighetti

Description

@lukepighetti

I'm just poking around with dart_codemod and I was wondering if someone would be willing to suggest/discuss a strategy for finding unused classes.

My idea was to visit every class declaration and get the name of the class, then search the rest of the AST for any use of the constructor. I tried to walk the tree and wasn't successful.

void main(List<String> arguments) {
  runInteractiveCodemod(
    filePathsFromGlob(Glob('**.dart', recursive: true)),
    PrintEveryCommentInProject(),
    args: arguments,
  );
}

class PrintEveryCommentInProject extends GeneralizingAstVisitor
    with AstVisitingSuggestorMixin {
  @override
  dynamic visitDeclaration(Declaration node) {
    print(node.documentationComment);

    node.visitChildren(this);
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions