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.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2020 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 java.util.Optional;
  23. import javax.annotation.CheckForNull;
  24. import org.sonar.server.project.Project;
  25. import org.sonar.server.qualityprofile.QualityProfile;
  26. public interface AnalysisMetadataHolder {
  27. /**
  28. * @throws IllegalStateException if organizations enabled flag has not been set
  29. */
  30. boolean isOrganizationsEnabled();
  31. /**
  32. * Returns the organization the analysis belongs to.
  33. * @throws IllegalStateException if organization has not been set
  34. */
  35. Organization getOrganization();
  36. /**
  37. * Returns the UUID generated for this analysis.
  38. * @throws IllegalStateException if uuid has not been set
  39. */
  40. String getUuid();
  41. /**
  42. * @throws IllegalStateException if no analysis date has been set
  43. */
  44. long getAnalysisDate();
  45. /**
  46. * Tell whether the analysisDate has been set.
  47. */
  48. boolean hasAnalysisDateBeenSet();
  49. /**
  50. * Convenience method equivalent to calling {@link #getBaseAnalysis() == null}
  51. *
  52. * @throws IllegalStateException if baseProjectSnapshot has not been set
  53. */
  54. boolean isFirstAnalysis();
  55. /**
  56. * Return the last analysis of the project.
  57. * If it's the first analysis, it will return null.
  58. *
  59. * @throws IllegalStateException if baseAnalysis has not been set
  60. */
  61. @CheckForNull
  62. Analysis getBaseAnalysis();
  63. /**
  64. * Convenience method equivalent to do the check using {@link #getBranch()}
  65. *
  66. * @throws IllegalStateException if branch has not been set
  67. */
  68. boolean isBranch();
  69. /**
  70. * Convenience method equivalent to do the check using {@link #getBranch()}
  71. *
  72. * @throws IllegalStateException if branch has not been set
  73. */
  74. boolean isPullRequest();
  75. /**
  76. * @throws IllegalStateException if cross project duplication flag has not been set
  77. */
  78. boolean isCrossProjectDuplicationEnabled();
  79. /**
  80. * Branch being analyzed.
  81. *
  82. * @throws IllegalStateException if branch has not been set
  83. */
  84. Branch getBranch();
  85. /**
  86. * In a pull request analysis, return the ID of the pull request
  87. *
  88. * @throws IllegalStateException if pull request key has not been set
  89. */
  90. String getPullRequestKey();
  91. /**
  92. * The project as represented by the main branch. It is used to load settings
  93. * like Quality gates, webhooks and configuration.
  94. *
  95. * In case of analysis of main branch, the returned value is the main branch,
  96. * so its uuid and key are the same in
  97. * {@link org.sonar.ce.task.projectanalysis.component.TreeRootHolder#getRoot().
  98. *
  99. * In case of analysis of non-main branch or pull request, the returned value
  100. * is the main branch. Its uuid and key are different than
  101. * {@link org.sonar.ce.task.projectanalysis.component.TreeRootHolder#getRoot().
  102. *
  103. * @throws IllegalStateException if project has not been set
  104. */
  105. Project getProject();
  106. /**
  107. * @throws IllegalStateException if root component ref has not been set
  108. */
  109. int getRootComponentRef();
  110. Map<String, QualityProfile> getQProfilesByLanguage();
  111. /**
  112. * Plugins used during the analysis on scanner side
  113. */
  114. Map<String, ScannerPlugin> getScannerPluginsByKey();
  115. /**
  116. * Scm Revision of the analysed code
  117. */
  118. Optional<String> getScmRevision();
  119. }