You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AnalysisMetadataHolder.java 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2019 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.ce.task.projectanalysis.analysis;
  21. import java.util.Map;
  22. import javax.annotation.CheckForNull;
  23. import org.sonar.server.project.Project;
  24. import org.sonar.server.qualityprofile.QualityProfile;
  25. public interface AnalysisMetadataHolder {
  26. /**
  27. * @throws IllegalStateException if organizations enabled flag has not been set
  28. */
  29. boolean isOrganizationsEnabled();
  30. /**
  31. * Returns the organization the analysis belongs to.
  32. * @throws IllegalStateException if organization has not been set
  33. */
  34. Organization getOrganization();
  35. /**
  36. * Returns the UUID generated for this analysis.
  37. * @throws IllegalStateException if uuid has not been set
  38. */
  39. String getUuid();
  40. /**
  41. * @throws IllegalStateException if no analysis date has been set
  42. */
  43. long getAnalysisDate();
  44. /**
  45. * Tell whether the analysisDate has been set.
  46. */
  47. boolean hasAnalysisDateBeenSet();
  48. /**
  49. * Convenience method equivalent to calling {@link #getBaseAnalysis() == null}
  50. *
  51. * @throws IllegalStateException if baseProjectSnapshot has not been set
  52. */
  53. boolean isFirstAnalysis();
  54. /**
  55. * Return the last analysis of the project.
  56. * If it's the first analysis, it will return null.
  57. *
  58. * @throws IllegalStateException if baseAnalysis has not been set
  59. */
  60. @CheckForNull
  61. Analysis getBaseAnalysis();
  62. /**
  63. * Convenience method equivalent to do the check using {@link #getBranch()}
  64. *
  65. * @throws IllegalStateException if branch has not been set
  66. */
  67. boolean isShortLivingBranch();
  68. /**
  69. * Convenience method equivalent to do the check using {@link #getBranch()}
  70. *
  71. * @throws IllegalStateException if branch has not been set
  72. */
  73. boolean isLongLivingBranch();
  74. /**
  75. * Convenience method equivalent to do the check using {@link #getBranch()}
  76. *
  77. * @throws IllegalStateException if branch has not been set
  78. */
  79. boolean isPullRequest();
  80. /**
  81. * @throws IllegalStateException if cross project duplication flag has not been set
  82. */
  83. boolean isCrossProjectDuplicationEnabled();
  84. /**
  85. * Branch being analyzed. Can be of any type: long or short, main or not.
  86. *
  87. * @throws IllegalStateException if branch has not been set
  88. */
  89. Branch getBranch();
  90. /**
  91. * In a pull request analysis, return the ID of the pull request
  92. *
  93. * @throws IllegalStateException if pull request key has not been set
  94. */
  95. String getPullRequestKey();
  96. /**
  97. * The project as represented by the main branch. It is used to load settings
  98. * like Quality gates, webhooks and configuration.
  99. *
  100. * In case of analysis of main branch, the returned value is the main branch,
  101. * so its uuid and key are the same in
  102. * {@link org.sonar.ce.task.projectanalysis.component.TreeRootHolder#getRoot().
  103. *
  104. * In case of analysis of non-main branch or pull request, the returned value
  105. * is the main branch. Its uuid and key are different than
  106. * {@link org.sonar.ce.task.projectanalysis.component.TreeRootHolder#getRoot().
  107. *
  108. * @throws IllegalStateException if project has not been set
  109. */
  110. Project getProject();
  111. /**
  112. * @throws IllegalStateException if root component ref has not been set
  113. */
  114. int getRootComponentRef();
  115. Map<String, QualityProfile> getQProfilesByLanguage();
  116. /**
  117. * Plugins used during the analysis on scanner side
  118. */
  119. Map<String, ScannerPlugin> getScannerPluginsByKey();
  120. }