Add Tool without using API

I write class for rule check message unused in file properties, but i’m not using Api Tree.
Here is my code :

package org.sonar.samples.java.checks;

import org.sonar.check.Rule;
import org.sonar.plugins.java.api.JavaFileScanner;
import org.sonar.plugins.java.api.JavaFileScannerContext;
import org.sonar.plugins.java.api.tree.BaseTreeVisitor;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.stream.Collectors;
import java.util.stream.Stream;


@Rule(key = "UnusedMessagePropertiesRule")
public class UnusedMessagePropertiesRule extends BaseTreeVisitor implements JavaFileScanner {

    private JavaFileScannerContext context;

    public  void main() throws IOException {
        List<String> keyUnused;
        int index = 1;
        UnusedMessagePropertiesRule app = new UnusedMessagePropertiesRule();
        keyUnused = app.checkUnused(app.getStringFile(app.getFileName(String.valueOf(Paths.get(System.getProperty("user.dir"))))));
        for(String key : keyUnused){
            context.addIssue(index,this, key);
            index++;
        }

    }

    @Override
    public void scanFile(JavaFileScannerContext javaFileScannerContext) {
        this.context = context;
        scan(context.getTree());
    }

    private List<String> getAllKey(){
        List<String> keyList = new ArrayList<>();
        try (InputStream input = getClass().getClassLoader().getResourceAsStream("messages/messages.properties")) {
            Properties prop = new Properties();
            prop.load(input);
            prop.keySet().forEach(x -> keyList.add((String) x));
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        return keyList;
    }

    private List<String> checkUnused(String fileCode){
        List<String> keyMessageList = getAllKey();
        keyMessageList.removeIf(fileCode::contains);
        return keyMessageList;
    }

    private  List<String> getFileName(String pathFile){

        List<String> result= null;
        try (Stream<Path> walk = Files.walk(Paths.get(pathFile))) {

            result = walk.map(Path::toString)
                    .filter(f -> f.endsWith(".java")).collect(Collectors.toList());

        } catch (IOException e) {
            e.printStackTrace();
        }
        return  result;
    }

    private  String getStringFile(List<String> pathList) throws IOException {
        List<String> lines ;
        List<String> getAllFile = new ArrayList<>();
        for(String line : pathList){
            lines = Files.readAllLines(Paths.get(line));
            getAllFile.addAll(lines);
        }
        return String.valueOf(getAllFile);
    }


}

FIle RuleList:

public final class RulesList {

    private RulesList() {
    }

    public static List<Class<? extends JavaCheck>> getChecks() {
        List<Class<? extends JavaCheck>> checks = new ArrayList<>();
        checks.addAll(getJavaChecks());
        checks.addAll(getJavaTestChecks());
        return Collections.unmodifiableList(checks);
    }

    public static List<Class<? extends JavaCheck>> getJavaChecks() {
        return Collections.unmodifiableList(Arrays.asList(
                UnusedMessagePropertiesRule.class,
                DuplicateCodeForCodeRule.class,
                DuplicateCommentForCodeRule.class,
                UnusedVariableForCodeRule.class
        ));
    }

    public static List<Class<? extends JavaCheck>> getJavaTestChecks() {
        return Collections.unmodifiableList(Arrays.asList(
                DuplicateCodeForTestRule.class,
                DuplicateCommentForTestRule.class,
                UnusedVariableForTestRule.class
        ));
    }
}

My wish is that when a developer removes the only usage space of an X key, the tool check pops up and says go to message.properties and delete that key X.

But it not working when i deploy,
How do I make it right is a rule check in sonarqube?