3 * Copyright (C) 2009-2017 SonarSource SA
4 * mailto:info AT sonarsource DOT com
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.
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.
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.
20 package org.sonar.server.computation.task.projectanalysis.analysis;
23 import java.util.Optional;
24 import javax.annotation.CheckForNull;
25 import org.sonar.server.qualityprofile.QualityProfile;
27 public interface AnalysisMetadataHolder {
30 * Returns the organization the analysis belongs to.
31 * @throws IllegalStateException if organization has not been set
33 Organization getOrganization();
36 * Returns the UUID generated for this analysis.
37 * @throws IllegalStateException if uuid has not been set
42 * @throws IllegalStateException if no analysis date has been set
44 long getAnalysisDate();
47 * Tell whether the analysisDate has been set.
49 boolean hasAnalysisDateBeenSet();
52 * Convenience method equivalent to calling {@link #getBaseAnalysis() == null}
54 * @throws IllegalStateException if baseProjectSnapshot has not been set
56 boolean isFirstAnalysis();
59 * Return the last analysis of the project.
60 * If it's the first analysis, it will return null.
62 * @throws IllegalStateException if baseAnalysis has not been set
65 Analysis getBaseAnalysis();
68 * Convenience method equivalent to do the check using {@link #getBranch()}
70 * @throws IllegalStateException if branch has not been set
72 boolean isShortLivingBranch();
75 * Convenience method equivalent to do the check using {@link #getBranch()}
77 * @throws IllegalStateException if branch has not been set
79 boolean isLongLivingBranch();
82 * @throws IllegalStateException if cross project duplication flag has not been set
84 boolean isCrossProjectDuplicationEnabled();
87 * Branch is present whatever the type of branch (long or short, main or not). However
88 * it is absent when analyzing a pull request.
90 * @throws IllegalStateException if branch has not been set
92 Optional<Branch> getBranch();
95 * The project as represented by the main branch. It is used to load settings
96 * like Quality gates, webhooks and configuration.
98 * In case of analysis of main branch, the returned value is the main branch,
99 * so its uuid and key are the same in
100 * {@link org.sonar.server.computation.task.projectanalysis.component.TreeRootHolder#getRoot().
102 * In case of analysis of non-main branch or pull request, the returned value
103 * is the main branch. Its uuid and key are different than
104 * {@link org.sonar.server.computation.task.projectanalysis.component.TreeRootHolder#getRoot().
106 * @throws IllegalStateException if project has not been set
108 Project getProject();
111 * @throws IllegalStateException if root component ref has not been set
113 int getRootComponentRef();
115 Map<String, QualityProfile> getQProfilesByLanguage();
118 * Plugins used during the analysis on scanner side
120 Map<String, ScannerPlugin> getScannerPluginsByKey();