Пользовательский плагин Sonarqube: ошибка неудовлетворенной зависимости при инициализации датчика - PullRequest
0 голосов
/ 16 апреля 2019

Я разрабатываю пользовательский плагин Java для добавления некоторых проверок i18n, но на моем пользовательском датчике обнаружена ошибка неудовлетворенной зависимости. Не могли бы вы помочь мне? Большое спасибо, я новичок в sonarqube ... и я искал похожие проблемы, но не был отсортирован.

Подробности, пожалуйста, найдите ниже: не стесняйтесь спрашивать, нужна ли дополнительная информация

  • SonarSever: 7,5
  • Sonar-java: sonar-java-plugin-5.9.2.16552.jar
  • Пользовательский язык: i18njava
  • пользовательский профиль: I18NProfile

Я пишу свой датчик, ссылаясь на импонент JavaSquidSensor.

Вот мой класс сеньоров:

@Phase(name = Phase.Name.PRE)
@DependsUpon("BEFORE_SQUID")
@DependedUpon("squid")
public class I18NJavaPreCheckSensor implements Sensor {

    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(I18NJavaPreCheckSensor.class);
    private static final JavaHardCodedCheck hcc = new JavaHardCodedCheck();

    private final SonarComponents sonarComponents;
    private final DefaultJavaResourceLocator javaResourceLocator;
    private final Configuration settings;
    private final NoSonarFilter noSonarFilter;
    private final PostAnalysisIssueFilter postAnalysisIssueFilter;
    private final FileSystem fs;

    public I18NJavaPreCheckSensor(SonarComponents sonarComponents, @Nullable FileSystem fs,
                                  @Nullable DefaultJavaResourceLocator javaResourceLocator, @Nullable Configuration settings, @Nullable NoSonarFilter noSonarFilter, @Nullable PostAnalysisIssueFilter postAnalysisIssueFilter) {
        System.out.println("nos: " +noSonarFilter.toString());
        this.noSonarFilter = noSonarFilter;
        this.sonarComponents = sonarComponents;
        this.javaResourceLocator = javaResourceLocator;
        this.settings = settings;
        this.postAnalysisIssueFilter = postAnalysisIssueFilter;
        System.out.println("postAnalysisIssueFilter: " +postAnalysisIssueFilter.toString());
        this.fs = fs;
        System.out.println("fs: " +fs.toString());

    }

    @Override
    public void describe(SensorDescriptor descriptor) {
        descriptor.onlyOnLanguage(Constants.LANGUAGE_KEY).name("I18NJavaPreCheckSensor");
    }

    @Override
    public void execute(SensorContext context) {
            javaResourceLocator.setSensorContext(context);
            sonarComponents.setSensorContext(context);

            List<Class<? extends JavaCheck>> checks = ImmutableList.<Class<? extends JavaCheck>>builder()
                    .addAll(I18NCheckClasses.getJavaChecks())
                    .build();
            sonarComponents.registerCheckClasses(I18NJavaRulesDefinition.REPOSITORY_KEY, checks);
            sonarComponents.registerTestCheckClasses(I18NJavaRulesDefinition.REPOSITORY_KEY,I18NCheckClasses.getJavaTestChecks());
            Measurer measurer = new Measurer(fs, context, noSonarFilter);
            I18NJavaSquid squid = new I18NJavaSquid(getJavaVersion(), isXFileEnabled(), sonarComponents, measurer, javaResourceLocator, postAnalysisIssueFilter, sonarComponents.checkClasses());
            squid.scan(getSourceFiles(), getTestFiles());
            sonarComponents.saveAnalysisErrors();

    }
    }

Я запускаю со сканера сонара, и получил ошибку ниже:

16:06:04.781 ERROR: Error during SonarQube Scanner execution
org.picocontainer.injectors.AbstractInjector$UnsatisfiableDependenciesException: i18n.sensor.I18NJavaPreCheckSensor has unsatisfied dependency 'class org.sonar.java.filters.PostAnalysisIssueFilter' for constructor 'public i18n.sensor.I18NJavaPreCheckSensor(org.sonar.java.SonarComponents,org.sonar.api.batch.fs.FileSystem,org.sonar.java.DefaultJavaResourceLocator,org.sonar.api.config.Configuration,org.sonar.api.issue.NoSonarFilter,org.sonar.java.filters.PostAnalysisIssueFilter)' from org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer@22c01ab0:151<[Immutable]:org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer@63a270c9:218<[Immutable]:org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer@4f4c4b1a:9<[Immutable]:org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer@53dfacba:37<|
        at org.picocontainer.injectors.ConstructorInjector.getGreediestSatisfiableConstructor(ConstructorInjector.java:191)
        at org.picocontainer.injectors.ConstructorInjector.getGreediestSatisfiableConstructor(ConstructorInjector.java:110)
        at org.picocontainer.injectors.ConstructorInjector.access$100(ConstructorInjector.java:51)
        at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:331)
        at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
        at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
        at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
        at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
        at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
        at org.picocontainer.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:606)
        at org.picocontainer.DefaultPicoContainer.getComponents(DefaultPicoContainer.java:587)
        at org.sonar.core.platform.ComponentContainer.getComponentsByType(ComponentContainer.java:290)
        at org.sonar.scanner.bootstrap.ScannerExtensionDictionnary.completeScannerExtensions(ScannerExtensionDictionnary.java:118)
        at org.sonar.scanner.bootstrap.ScannerExtensionDictionnary.getExtensions(ScannerExtensionDictionnary.java:113)
        at org.sonar.scanner.bootstrap.ScannerExtensionDictionnary.getFilteredExtensions(ScannerExtensionDictionnary.java:103)
        at org.sonar.scanner.bootstrap.ScannerExtensionDictionnary.selectSensors(ScannerExtensionDictionnary.java:77)
        at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:55)
        at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:74)
        at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:164)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:319)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:314)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:288)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
        at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:82)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:131)
        at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
        at com.sun.proxy.$Proxy0.execute(Unknown Source)
        at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:185)
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
        at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...