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 3.7KB

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