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 * Whether this is an incremental analysis or a full analysis.
61 boolean isIncrementalAnalysis();
64 * Return the last analysis of the project.
65 * If it's the first analysis, it will return null.
67 * @throws IllegalStateException if baseAnalysis has not been set
70 Analysis getBaseAnalysis();
73 * Convenience method equivalent to do the check using {@link #getBranch()}
75 * @throws IllegalStateException if branch has not been set
77 boolean isShortLivingBranch();
80 * @throws IllegalStateException if cross project duplication flag has not been set
82 boolean isCrossProjectDuplicationEnabled();
85 * Branch is present whatever the type of branch (long or short, main or not). However
86 * it is absent when analyzing a pull request.
88 * @throws IllegalStateException if branch has not been set
90 Optional<Branch> getBranch();
93 * The project as represented by the main branch. It is used to load settings
94 * like Quality gates, webhooks and configuration.
96 * In case of analysis of main branch, the returned value is the main branch,
97 * so its uuid and key are the same in
98 * {@link org.sonar.server.computation.task.projectanalysis.component.TreeRootHolder#getRoot().
100 * In case of analysis of non-main branch or pull request, the returned value
101 * is the main branch. Its uuid and key are different than
102 * {@link org.sonar.server.computation.task.projectanalysis.component.TreeRootHolder#getRoot().
104 * @throws IllegalStateException if project has not been set
106 Project getProject();
109 * @throws IllegalStateException if root component ref has not been set
111 int getRootComponentRef();
113 Map<String, QualityProfile> getQProfilesByLanguage();
116 * Plugins used during the analysis on scanner side
118 Map<String, ScannerPlugin> getScannerPluginsByKey();