本文整理汇总了Java中org.sonar.api.component.ResourcePerspectives类的典型用法代码示例。如果您正苦于以下问题:Java ResourcePerspectives类的具体用法?Java ResourcePerspectives怎么用?Java ResourcePerspectives使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResourcePerspectives类属于org.sonar.api.component包,在下文中一共展示了ResourcePerspectives类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FlowSquidSensor
import org.sonar.api.component.ResourcePerspectives; //导入依赖的package包/类
public FlowSquidSensor(Settings settings, CheckFactory checkFactory, FileLinesContextFactory fileLinesContextFactory,
FileSystem fileSystem, ResourcePerspectives resourcePerspectives, PathResolver pathResolver) {
logger.debug("** FlowSquidSenser constructor");
this.settings = settings;
this.pathResolver = pathResolver;
this.checks = checkFactory
.<SquidCheck<Grammar>>create(CheckList.REPOSITORY_KEY)
.addAnnotatedChecks((Iterable)CheckList.getChecks(settings.getBoolean(FlowPlugin.IGNORE_TOPLEVEL_KEY),false));
this.nodeChecks = checkFactory
.<SquidCheck<Grammar>>create(CheckList.REPOSITORY_KEY)
.addAnnotatedChecks((Iterable)CheckList.getChecks(settings.getBoolean(FlowPlugin.IGNORE_TOPLEVEL_KEY), true));
this.fileLinesContextFactory = fileLinesContextFactory;
this.fileSystem = fileSystem;
this.resourcePerspectives = resourcePerspectives;
this.mainFilePredicates = fileSystem.predicates().and(
fileSystem.predicates().hasLanguage(FlowLanguage.KEY),
fileSystem.predicates().hasType(InputFile.Type.MAIN));
}
示例2: createIssueSensorBackedByMocks
import org.sonar.api.component.ResourcePerspectives; //导入依赖的package包/类
@Before
public void createIssueSensorBackedByMocks() {
ResourcePerspectives resourcePerspectives = mock(ResourcePerspectives.class);
Checks<Object> checks = mock(Checks.class);
CheckFactory checkFactory = mock(CheckFactory.class);
when(checkFactory.create(Mockito.anyString())).thenReturn(checks);
List<Object> checksList = Arrays.asList(new Object[] {realIfOneStringExistsBothMustExistMultiFileCheck});
when(checks.all()).thenReturn(checksList);
when(checks.ruleKey(Mockito.isA(StringDisallowedIfMatchInAnotherFileCheck.class))).thenReturn(RuleKey.of("text", "StringDisallowedIfMatchInAnotherFileCheck"));
when(checks.ruleKey(Mockito.isA(MultiFileIfOneStringExistsThenBothMustExistCheck.class))).thenReturn(RuleKey.of("text", "MultiFileIfOneStringExistsThenBothMustExistCheck"));
// realStringDisallowedMultiFileCheck.setRuleKey(RuleKey.parse("text:StringDisallowedIfMatchInAnotherFileCheck")); // Not strictly necessary here. Normally set by the framework to the value in the Check class's annotation
when(checks.addAnnotatedChecks(Mockito.anyCollection())).thenReturn(checks);
mockIssuable = mock(Issuable.class);
when(resourcePerspectives.as(Mockito.eq(Issuable.class), Mockito.isA(InputFile.class))).thenReturn(mockIssuable);
IssueBuilder mockIssueBuilder = mock(IssueBuilder.class);
when(mockIssuable.newIssueBuilder()).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.ruleKey(Mockito.isA(RuleKey.class))).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.line(Mockito.anyInt())).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.message(Mockito.anyString())).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.build()).thenReturn(mock(Issue.class));
sensor = new TextIssueSensor(fs, resourcePerspectives, checkFactory, project);
}
开发者ID:gjd6640,项目名称:sonar-text-plugin,代码行数:26,代码来源:MultiFileIfOneExistsThenBothMustExistCheckTest.java
示例3: createIssueSensorBackedByMocks
import org.sonar.api.component.ResourcePerspectives; //导入依赖的package包/类
@Before
public void createIssueSensorBackedByMocks() {
ResourcePerspectives resourcePerspectives = mock(ResourcePerspectives.class);
Checks<Object> checks = mock(Checks.class);
CheckFactory checkFactory = mock(CheckFactory.class);
when(checkFactory.create(Mockito.anyString())).thenReturn(checks);
List<Object> checksList = Arrays.asList(new Object[] {realStringDisallowedMultiFileCheck});
when(checks.all()).thenReturn(checksList);
when(checks.ruleKey(Mockito.isA(StringDisallowedIfMatchInAnotherFileCheck.class))).thenReturn(RuleKey.of("text", "StringDisallowedIfMatchInAnotherFileCheck"));
// realStringDisallowedMultiFileCheck.setRuleKey(RuleKey.parse("text:StringDisallowedIfMatchInAnotherFileCheck")); // Not strictly necessary here. Normally set by the framework to the value in the Check class's annotation
when(checks.addAnnotatedChecks(Mockito.anyCollection())).thenReturn(checks);
mockIssuable = mock(Issuable.class);
when(resourcePerspectives.as(Mockito.eq(Issuable.class), Mockito.isA(InputFile.class))).thenReturn(mockIssuable);
IssueBuilder mockIssueBuilder = mock(IssueBuilder.class);
when(mockIssuable.newIssueBuilder()).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.ruleKey(Mockito.isA(RuleKey.class))).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.line(Mockito.anyInt())).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.message(Mockito.anyString())).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.build()).thenReturn(mock(Issue.class));
sensor = new TextIssueSensor(fs, resourcePerspectives, checkFactory, project);
}
开发者ID:gjd6640,项目名称:sonar-text-plugin,代码行数:25,代码来源:StringDisallowedIfMatchInAnotherFileCheckTest.java
示例4: createIssueSensorBackedByMocks
import org.sonar.api.component.ResourcePerspectives; //导入依赖的package包/类
@Before
public void createIssueSensorBackedByMocks() {
ResourcePerspectives resourcePerspectives = mock(ResourcePerspectives.class);
Checks<Object> checks = mock(Checks.class);
CheckFactory checkFactory = mock(CheckFactory.class);
when(checkFactory.create(Mockito.anyString())).thenReturn(checks);
textCheckMock = mock(AbstractTextCheck.class);
List<Object> checksList = Arrays.asList(new Object[] {textCheckMock});
when(checks.all()).thenReturn(checksList);
when(checks.addAnnotatedChecks(Mockito.anyCollection())).thenReturn(checks);
mockIssuable = mock(Issuable.class);
when(resourcePerspectives.as(Mockito.eq(Issuable.class), Mockito.isA(InputFile.class))).thenReturn(mockIssuable);
IssueBuilder mockIssueBuilder = mock(IssueBuilder.class);
when(mockIssuable.newIssueBuilder()).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.ruleKey(Mockito.isA(RuleKey.class))).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.line(Mockito.anyInt())).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.message(Mockito.anyString())).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.build()).thenReturn(mock(Issue.class));
sensor = new TextIssueSensor(fs, resourcePerspectives, checkFactory, project);
}
示例5: shouldExecuteOnProject
import org.sonar.api.component.ResourcePerspectives; //导入依赖的package包/类
@Test
public void shouldExecuteOnProject() {
Settings settings = mock(Settings.class);
RulesProfile profile = mock(RulesProfile.class);
DefaultFileSystem fileSystem = new DefaultFileSystem();
ResourcePerspectives perspectives = mock(ResourcePerspectives.class);
Project project = mock(Project.class);
ReSharperSensor sensor = new ReSharperSensor(
new ReSharperConfiguration("lang", "foo-resharper", "fooReportkey"),
settings, profile, fileSystem, perspectives);
assertThat(sensor.shouldExecuteOnProject(project)).isFalse();
fileSystem.add(new DefaultInputFile("").setAbsolutePath("").setLanguage("foo"));
when(profile.getActiveRulesByRepository("foo-resharper")).thenReturn(ImmutableList.<ActiveRule>of());
assertThat(sensor.shouldExecuteOnProject(project)).isFalse();
fileSystem.add(new DefaultInputFile("").setAbsolutePath("").setLanguage("lang"));
when(profile.getActiveRulesByRepository("foo-resharper")).thenReturn(ImmutableList.of(mock(ActiveRule.class)));
assertThat(sensor.shouldExecuteOnProject(project)).isTrue();
when(profile.getActiveRulesByRepository("foo-resharper")).thenReturn(ImmutableList.<ActiveRule>of());
assertThat(sensor.shouldExecuteOnProject(project)).isFalse();
}
示例6: CoverageSensor
import org.sonar.api.component.ResourcePerspectives; //导入依赖的package包/类
public CoverageSensor(FileSystem fileSystem, ResourcePerspectives perspectives,
CoverageConfiguration config, ActiveRules activeRules,
CoverageProjectStore coverageProjectStore, SonarClient sonar) {
this.fileSystem = fileSystem;
this.perspectives = perspectives;
this.config = config;
this.activeRules = activeRules;
this.coverageProjectStore = coverageProjectStore;
this.sonar = sonar;
}
示例7: ApexSquidSensor
import org.sonar.api.component.ResourcePerspectives; //导入依赖的package包/类
/**
* Default construct to initialize the variables.
*
* @param fileSystem source files.
* @param perspectives perspective from resources.
* @param checkFactory factory to create a check.
*/
public ApexSquidSensor(FileSystem fileSystem, ResourcePerspectives perspectives, CheckFactory checkFactory) {
this.checks = checkFactory
.<SquidAstVisitor<Grammar>>create(CheckList.REPOSITORY_KEY)
.addAnnotatedChecks(CheckList.getChecks());
this.fileSystem = fileSystem;
this.resourcePerspectives = perspectives;
FilePredicates predicates = fileSystem.predicates();
filePredicate = predicates.and(
predicates.hasType(InputFile.Type.MAIN),
predicates.hasLanguage(Apex.KEY));
}
示例8: setUp
import org.sonar.api.component.ResourcePerspectives; //导入依赖的package包/类
@Before
public void setUp() {
ActiveRules activeRules = (new ActiveRulesBuilder())
.create(RuleKey.of(CheckList.REPOSITORY_KEY, "PrintStatementUsage"))
.setName("Print Statement Usage")
.activate()
.build();
CheckFactory checkFactory = new CheckFactory(activeRules);
perspectives = mock(ResourcePerspectives.class);
fileSystem = new DefaultFileSystem(new File("."));
squidSensor = new ApexSquidSensor(fileSystem, perspectives, checkFactory);
}
示例9: TextIssueSensor
import org.sonar.api.component.ResourcePerspectives; //导入依赖的package包/类
/**
* Use of IoC to get FileSystem
*/
public TextIssueSensor(final FileSystem fs, final ResourcePerspectives perspectives, final CheckFactory checkFactory, final Project project) {
this.checks = checkFactory.create(CheckRepository.REPOSITORY_KEY).addAnnotatedChecks(CheckRepository.getCheckClasses());
this.fs = fs;
this.resourcePerspectives = perspectives;
this.project = project;
// This data structure is shared across all cross-file checks so they can see each others' data.
// Each file with any trigger or disallow match gets a listitem indicating the specifics of the Check that matched including line number. This object reference stays with the check and gets referenced later inside the "raiseIssuesAfterScan()" method call.
this.crossFileChecksRawResults = Maps.newHashMap();
}
示例10: IssueSensor
import org.sonar.api.component.ResourcePerspectives; //导入依赖的package包/类
/**
* Use of IoC to get FileSystem
*/
public IssueSensor(FileSystem fs, ResourcePerspectives perspectives, ActiveRules activeRules) {
this.fs = fs;
this.perspectives = perspectives;
this.activeRules = activeRules;
this.activeRules.toString(); // could be used
}
示例11: ReSharperSensor
import org.sonar.api.component.ResourcePerspectives; //导入依赖的package包/类
public ReSharperSensor(ReSharperConfiguration reSharperConf, Settings settings, RulesProfile profile, FileSystem fileSystem, ResourcePerspectives perspectives) {
this.reSharperConf = reSharperConf;
this.settings = settings;
this.profile = profile;
this.fileSystem = fileSystem;
this.perspectives = perspectives;
}
示例12: testSensorInstantiation
import org.sonar.api.component.ResourcePerspectives; //导入依赖的package包/类
@Test
public void testSensorInstantiation() throws Exception {
CSharpReSharperSensor sensor = new CSharpReSharperSensor(new Settings(), mock(RulesProfile.class), new DefaultFileSystem(), mock(ResourcePerspectives.class));
ReSharperConfiguration configuration = sensor.getConfiguration();
assertThat(configuration.languageKey()).isEqualTo("cs");
assertThat(configuration.repositoryKey()).isEqualTo("resharper-cs");
assertThat(configuration.reportPathKey()).isEqualTo("sonar.resharper.cs.reportPath");
}
示例13: testSensorInstantiation
import org.sonar.api.component.ResourcePerspectives; //导入依赖的package包/类
@Test
public void testSensorInstantiation() throws Exception {
VBNetReSharperSensor sensor = new VBNetReSharperSensor(new Settings(), mock(RulesProfile.class), new DefaultFileSystem(), mock(ResourcePerspectives.class));
ReSharperConfiguration configuration = sensor.getConfiguration();
assertThat(configuration.languageKey()).isEqualTo("vbnet");
assertThat(configuration.repositoryKey()).isEqualTo("resharper-vbnet");
assertThat(configuration.reportPathKey()).isEqualTo("sonar.resharper.vbnet.reportPath");
}
示例14: CheckstyleAuditListener
import org.sonar.api.component.ResourcePerspectives; //导入依赖的package包/类
public CheckstyleAuditListener(RuleFinder ruleFinder, FileSystem fileSystem,
ResourcePerspectives perspectives) {
this.ruleFinder = ruleFinder;
this.fileSystem = fileSystem;
this.perspectives = perspectives;
}
示例15: setup
import org.sonar.api.component.ResourcePerspectives; //导入依赖的package包/类
@Before
public void setup() {
decorator = new ApexCommonRulesDecorator(mock(FileSystem.class),
mock(CheckFactory.class),
mock(ResourcePerspectives.class));
}