return bytecodeScanned;
}
- public void initSonarProxy(SquidSearchProxy proxy) {
+ void flush() {
squid.flush();
- proxy.setTarget(squid);
}
public Squid getSquid() {
}
public List getExtensions() {
- return Arrays.asList(SquidSearchProxy.class, SquidSensor.class, SquidRuleRepository.class, JavaSourceImporter.class,
+ return Arrays.asList(SquidSensor.class, SquidRuleRepository.class, JavaSourceImporter.class,
ClassComplexityDistributionBuilder.class, FunctionComplexityDistributionBuilder.class, ClassesDecorator.class,
ChidamberKemererDistributionBuilder.class, FunctionsDecorator.class);
}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.squid;
-
-import java.util.Collection;
-
-import org.sonar.api.BatchExtension;
-import org.sonar.api.batch.SquidSearch;
-import org.sonar.squid.Squid;
-import org.sonar.squid.api.Query;
-import org.sonar.squid.api.SourceCode;
-
-public class SquidSearchProxy implements SquidSearch, BatchExtension {
-
- private Squid target;
-
- public Squid getTarget() {
- return target;
- }
-
- public void setTarget(Squid target) {
- this.target = target;
- }
-
- public Collection<SourceCode> search(Query... query) {
- checkTarget();
- return target.search(query);
- }
-
- public SourceCode search(String key) {
- checkTarget();
- return target.search(key);
- }
-
- private void checkTarget() {
- if (target == null) {
- throw new IllegalStateException("Squid service is not initialized");
- }
- }
-}
@DependedUpon(value = JavaUtils.BARRIER_AFTER_SQUID, classes = NoSonarFilter.class)
public class SquidSensor implements Sensor {
- private SquidSearchProxy proxy;
private NoSonarFilter noSonarFilter;
private RulesProfile profile;
private ProjectClasspath projectClasspath;
private ResourceCreationLock lock;
- public SquidSensor(RulesProfile profile, SquidSearchProxy proxy, NoSonarFilter noSonarFilter, ProjectClasspath projectClasspath, ResourceCreationLock lock) {
- this.proxy = proxy;
+ public SquidSensor(RulesProfile profile, NoSonarFilter noSonarFilter, ProjectClasspath projectClasspath, ResourceCreationLock lock) {
this.noSonarFilter = noSonarFilter;
this.profile = profile;
this.projectClasspath = projectClasspath;
SquidExecutor squidExecutor = new SquidExecutor(analyzePropertyAccessors, fieldNamesToExcludeFromLcom4Computation, factory, charset);
squidExecutor.scan(getMainSourceFiles(project), getMainBytecodeFiles(project));
squidExecutor.save(project, context, noSonarFilter);
- squidExecutor.initSonarProxy(proxy);
+ squidExecutor.flush();
}
private void browseTestSources(Project project, SensorContext context) {
assertTrue(SquidExecutor.hasBytecode(Arrays.asList(new File("test-resources/commons-collections-3.2.1/bin"))));
}
- @Test
- public void flushSquidAfterUsage() {
- Squid squid = mock(Squid.class);
- SquidExecutor executor = new SquidExecutor(squid);
- executor.initSonarProxy(new SquidSearchProxy());
-
- verify(squid).flush();
- }
-
private CheckFactory createCheckFactory() {
RulesProfile profile = RulesProfile.create();
CheckFactory checkFactory = AnnotationCheckFactory.create(profile, "repo", Collections.<Class> emptyList());
@Test
public void coverageForFun() {
assertThat(new SquidPlugin().getKey(), not(nullValue()));
- assertThat(new SquidPlugin().getExtensions().size(), is(9));
+ assertThat(new SquidPlugin().getExtensions().size(), is(8));
}
}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.squid;
-
-import org.junit.Test;
-import org.sonar.squid.Squid;
-import org.sonar.squid.api.SourceFile;
-import org.sonar.squid.indexer.QueryByType;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-public class SquidSearchProxyTest {
-
- @Test
- public void isProxy() {
- Squid squid = mock(Squid.class);
- SquidSearchProxy proxy = new SquidSearchProxy();
- proxy.setTarget(squid);
-
- proxy.search("foo");
- verify(squid).search("foo");
-
- QueryByType query = new QueryByType(SourceFile.class);
- proxy.search(query);
- verify(squid).search(query);
- }
-}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.batch;
-
-import java.util.Collection;
-
-import org.sonar.api.BatchExtension;
-import org.sonar.squid.api.Query;
-import org.sonar.squid.api.SourceCode;
-
-/**
- * The extension point to access the Squid data tree
- *
- * @since 1.11
- * @deprecated since 2.6. Data on classes/methods are now injected into sonar index. There's no need to use
- * this component anymore.
- */
-@Deprecated
-public interface SquidSearch extends BatchExtension {
- /**
- * Returns a list of SourceCode objects base a set of queries given
- *
- * @param query the set of query
- * @return SourceCode objects
- */
- Collection<SourceCode> search(Query... query);
-
- /**
- * Returns a SourceObject given its key
- *
- * @param key the key
- * @return SourceCode object
- */
- SourceCode search(String key);
-}