当前位置: 首页>>代码示例>>Java>>正文


Java Issue类代码示例

本文整理汇总了Java中org.sonar.api.issue.Issue的典型用法代码示例。如果您正苦于以下问题:Java Issue类的具体用法?Java Issue怎么用?Java Issue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Issue类属于org.sonar.api.issue包,在下文中一共展示了Issue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addErrorTest

import org.sonar.api.issue.Issue; //导入依赖的package包/类
@Test
public void addErrorTest() {
    final Rule rule = setupRule("repo", "key");

    final Issuable issuable = setupIssuable();
    final IssueBuilder issueBuilder = mock(IssueBuilder.class);
    final Issue issue = mock(Issue.class);
    when(issuable.newIssueBuilder()).thenReturn(issueBuilder);
    when(issueBuilder.ruleKey(RuleKey.of("repo", "key"))).thenReturn(issueBuilder);
    when(issueBuilder.message(event.getMessage())).thenReturn(issueBuilder);
    when(issueBuilder.line(event.getLine())).thenReturn(issueBuilder);
    when(issueBuilder.build()).thenReturn(issue);

    addErrorToListener();

    verify(issuable).addIssue(issue);
    verify(issueBuilder).ruleKey(RuleKey.of("repo", "key"));
    verify(issueBuilder).message(event.getMessage());
    verify(issueBuilder).line(event.getLine());
    verify(rule).ruleKey();
}
 
开发者ID:checkstyle,项目名称:sonar-checkstyle,代码行数:22,代码来源:CheckstyleAuditListenerTest.java

示例2: saveIssues

import org.sonar.api.issue.Issue; //导入依赖的package包/类
/**
 * Saves issues form input file and source file.
 *
 * @param sonarFile input file.
 * @param squidFile source file.
 */
private void saveIssues(InputFile sonarFile, SourceFile squidFile) {
    Collection<CheckMessage> messages = squidFile.getCheckMessages();
    messages.forEach(message -> {
        RuleKey ruleKey = checks.ruleKey((SquidAstVisitor<Grammar>) message.getCheck());
        Issuable issuable = resourcePerspectives.as(Issuable.class, sonarFile);

        if (issuable != null) {
            Issue issue = issuable.newIssueBuilder()
                    .ruleKey(ruleKey)
                    .line(message.getLine())
                    .message(message.getText(Locale.ENGLISH))
                    .build();
            issuable.addIssue(issue);
        }
    });
}
 
开发者ID:fundacionjala,项目名称:enforce-sonarqube-plugin,代码行数:23,代码来源:ApexSquidSensor.java

示例3: updateCountsWithResolvedIssues

import org.sonar.api.issue.Issue; //导入依赖的package包/类
protected static void updateCountsWithResolvedIssues(Map<String, SeverityCount> severityCountMap, List<Issue> issuesResolved) {
	for (Issue issue : issuesResolved) {
		String severity = issue.severity();

		SeverityCount count = severityCountMap.get(severity);
		if (count == null) {
			count = new SeverityCount();
		}

		long resolvedCount = count.getResolvedCount() + 1;

		count.setResolvedCount(resolvedCount);

		severityCountMap.put(severity, count);
	}
}
 
开发者ID:Leviter,项目名称:sonar-slack-plugin,代码行数:17,代码来源:SlackMessageBuilder.java

示例4: updateCountsWithIssues

import org.sonar.api.issue.Issue; //导入依赖的package包/类
protected static void updateCountsWithIssues(Map<String, SeverityCount> severityCountMap, List<Issue> issues) {
	for (Issue issue : issues) {
		boolean isNew = issue.isNew();
		String severity = issue.severity();

		SeverityCount count = severityCountMap.get(severity);
		if (count == null) {
			count = new SeverityCount();
		}

		long totalCount = count.getTotalCount() + 1;
		long newCount = count.getNewCount() + (isNew ? 1 : 0);

		count.setTotalCount(totalCount);
		count.setNewCount(newCount);

		severityCountMap.put(severity, count);
	}
}
 
开发者ID:Leviter,项目名称:sonar-slack-plugin,代码行数:20,代码来源:SlackMessageBuilder.java

示例5: testUpdateCountsMustKeepTrackOfAllUniqueSeveritiesAndIncreaseCountForNewIssues

import org.sonar.api.issue.Issue; //导入依赖的package包/类
@Test
public void testUpdateCountsMustKeepTrackOfAllUniqueSeveritiesAndIncreaseCountForNewIssues() {
	List<Issue> issues = new ArrayList<>();
	Map<String, SeverityCount> result = new HashMap<>();

	Issue issue = new DummyIssue(Severity.BLOCKER, true);
	issues.add(issue);
	issues.add(issue);

	SlackMessageBuilder.updateCountsWithIssues(result, issues);

	assertThat(result.size(), is(1));
	assertThat(result.get(Severity.BLOCKER).getTotalCount(), is(2L));
	assertThat(result.get(Severity.BLOCKER).getNewCount(), is(2L));
	assertThat(result.get(Severity.BLOCKER).getResolvedCount(), is(0L));
}
 
开发者ID:Leviter,项目名称:sonar-slack-plugin,代码行数:17,代码来源:SlackMessageBuilderTest.java

示例6: testUpdateCountsMustKeepTrackOfAllUniqueSeveritiesAndIncreaseCountForResolvedIssues

import org.sonar.api.issue.Issue; //导入依赖的package包/类
@Test
public void testUpdateCountsMustKeepTrackOfAllUniqueSeveritiesAndIncreaseCountForResolvedIssues() {
	List<Issue> issues = new ArrayList<>();
	List<Issue> resolvedIssues = new ArrayList<>();
	Map<String, SeverityCount> result = new HashMap<>();

	issues.add(new DummyIssue(Severity.BLOCKER, false));
	issues.add(new DummyIssue(Severity.BLOCKER, true));
	resolvedIssues.add(new DummyIssue(Severity.BLOCKER, false));

	SlackMessageBuilder.updateCountsWithIssues(result, issues);
	SlackMessageBuilder.updateCountsWithResolvedIssues(result, resolvedIssues);

	assertThat(result.size(), is(1));
	assertThat(result.get(Severity.BLOCKER).getTotalCount(), is(2L));
	assertThat(result.get(Severity.BLOCKER).getNewCount(), is(1L));
	assertThat(result.get(Severity.BLOCKER).getResolvedCount(), is(1L));
}
 
开发者ID:Leviter,项目名称:sonar-slack-plugin,代码行数:19,代码来源:SlackMessageBuilderTest.java

示例7: createIssueSensorBackedByMocks

import org.sonar.api.issue.Issue; //导入依赖的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

示例8: createIssueSensorBackedByMocks

import org.sonar.api.issue.Issue; //导入依赖的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

示例9: analyse

import org.sonar.api.issue.Issue; //导入依赖的package包/类
@Test
 public void analyse() {
// Setup
SensorContext sensorContext = mock(SensorContext.class);

// Run
fs.add(createInputFile("setup.properties", TextLanguage.LANGUAGE_KEY));

Mockito.doAnswer(new Answer<Void>() {
	@Override
	public Void answer(final InvocationOnMock invocation) throws Throwable {
		TextSourceFile sourceFile = (TextSourceFile)invocation.getArguments()[0];
		sourceFile.addViolation(new TextIssue(mock(RuleKey.class), 1, "rule violated"));
		return null;
	}
}).when(textCheckMock).validate(Mockito.any(TextSourceFile.class), Mockito.matches("com.mycorp.projectA.service:service-do-X"));

   sensor.analyse(project, sensorContext);

   verify(mockIssuable).addIssue(Mockito.isA(Issue.class));
 }
 
开发者ID:gjd6640,项目名称:sonar-text-plugin,代码行数:22,代码来源:IssueSensorTest.java

示例10: createIssueSensorBackedByMocks

import org.sonar.api.issue.Issue; //导入依赖的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);
}
 
开发者ID:gjd6640,项目名称:sonar-text-plugin,代码行数:23,代码来源:IssueSensorTest.java

示例11: getCost

import org.sonar.api.issue.Issue; //导入依赖的package包/类
@Override
public BigDecimal getCost(Issue issue) {

    List<BigDecimal> params = parseMessage(issue);
    if (params.size() < 2) {
        throw new IllegalArgumentException("Invalid message "
                + issue.message()
                + ". Two integral parameters was expected");
    }

    if (params.get(REQUIRED_VALUE_INDEX).compareTo(BigDecimal.ZERO) == 0) {
        LOGGER.warn("Invalid devisor in message: {}", issue.message());
        return BigDecimal.ZERO;
    }

    return params.get(VALUE_INDEX).divide(params.get(REQUIRED_VALUE_INDEX),
            MathContext.DECIMAL32);
}
 
开发者ID:cezarcoca,项目名称:sonar-toxicity-chart,代码行数:19,代码来源:TwoValuesCostProcessor.java

示例12: whenDecorateIsInvokedThenAllViolationsShouldBeProcessed

import org.sonar.api.issue.Issue; //导入依赖的package包/类
@Test
public void whenDecorateIsInvokedThenAllViolationsShouldBeProcessed() {

  int count = 10;

  DecoratorContext context = mock(DecoratorContext.class);
  Resource resource = mock(Resource.class);
  configureProject("Java");

  List<Issue> issues = new ArrayList<Issue>();
  for (int i = 0; i < count; i++) {
    issues.add(createIssue("", DebtProcessorFactory.MISSING_SWITCH_DEFAULT_CHECK_STYLE, ""));
  }

  Issuable issuable = mock(Issuable.class);
  when(issuable.issues()).thenReturn(issues);

  when(perspectivesMock.as(Issuable.class, resource)).thenReturn(issuable);

  decorator.decorate(resource, context);
}
 
开发者ID:cezarcoca,项目名称:sonar-toxicity-chart,代码行数:22,代码来源:ToxicityChartDecoratorTest.java

示例13: doCreateIssue

import org.sonar.api.issue.Issue; //导入依赖的package包/类
protected RemoteIssue doCreateIssue(Issue sonarIssue, JiraSoapSession soapSession, Settings settings, String commentText) {
  // Connect to JIRA
  String jiraUrl = settings.getString(JiraConstants.SERVER_URL_PROPERTY);
  String userName = settings.getString(JiraConstants.USERNAME_PROPERTY);
  String password = settings.getString(JiraConstants.PASSWORD_PROPERTY);
  try {
    soapSession.connect(userName, password);
  } catch (RemoteException e) {
    throw new IllegalStateException("Impossible to connect to the JIRA server (" + jiraUrl + ").", e);
  }

  // The JIRA SOAP Service and authentication token are used to make authentication calls
  JiraSoapService jiraSoapService = soapSession.getJiraSoapService();
  String authToken = soapSession.getAuthenticationToken();

  // And create the issue
  RemoteIssue issue = initRemoteIssue(sonarIssue, settings, commentText);
  RemoteIssue returnedIssue = sendRequest(jiraSoapService, authToken, issue, jiraUrl, userName);

  String issueKey = returnedIssue.getKey();
  LOG.debug("Successfully created issue {}", issueKey);

  return returnedIssue;
}
 
开发者ID:aifraenkel,项目名称:caltec-tools,代码行数:25,代码来源:JiraIssueCreator.java

示例14: generateIssueSummary

import org.sonar.api.issue.Issue; //导入依赖的package包/类
protected String generateIssueSummary(Issue sonarIssue) {
sonarIssue.ruleKey().repository();
RuleI18nManager manager = null;
Rule rule = ruleFinder.findByKey(sonarIssue.ruleKey());
   String str3 = rule.getName();

   StringBuilder summary = new StringBuilder("Sonar Issue");
   summary.append(" - ");
   if (str3 != null)
   {
   	summary.append(str3);
   }
   else
   {
   	summary.append(sonarIssue.ruleKey().rule());
   }
   //summary.append(" - ");
//summary.append(sonarIssue.message());
   return summary.toString();
 }
 
开发者ID:aifraenkel,项目名称:caltec-tools,代码行数:21,代码来源:JiraIssueCreator.java

示例15: generateIssueDescription

import org.sonar.api.issue.Issue; //导入依赖的package包/类
protected String generateIssueDescription(Issue sonarIssue, Settings settings, String commentText) {
  StringBuilder description = new StringBuilder("Issue detail:");
  description.append(QUOTE);
  description.append(sonarIssue.message());
  description.append(QUOTE);
  if (StringUtils.isNotBlank(commentText)) {
  	description.append("\nMessage from reviewer:");
  	description.append(QUOTE);
  	description.append(commentText);
  	description.append(QUOTE);
  }
  description.append("\n\nCheck it on Sonar: ");
  description.append(settings.getString(CoreProperties.SERVER_BASE_URL));
  description.append("/issue/show/");
  description.append(sonarIssue.key());
  return description.toString();
}
 
开发者ID:aifraenkel,项目名称:caltec-tools,代码行数:18,代码来源:JiraIssueCreator.java


注:本文中的org.sonar.api.issue.Issue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。