001/*
002 * SonarQube
003 * Copyright (C) 2009-2017 SonarSource SA
004 * mailto:info AT sonarsource DOT com
005 *
006 * This program is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * This program is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public License
017 * along with this program; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
019 */
020package org.sonar.api.batch.sensor;
021
022import org.sonar.api.batch.fs.InputFile;
023
024/**
025 * Describe what a {@link Sensor} is doing. Information may be used by the platform
026 * to log interesting information or perform some optimization.
027 * See {@link Sensor#describe(SensorDescriptor)}
028 * @since 5.1
029 */
030public interface SensorDescriptor {
031
032  /**
033   * Displayable name of the {@link Sensor}. Will be displayed in logs.
034   */
035  SensorDescriptor name(String sensorName);
036
037  /**
038   * Language this {@link Sensor} work on. Used by the platform to skip execution of the {@link Sensor} when
039   * no file for given languages are present in the project.
040   * Default is to execute sensor for all languages.
041   */
042  SensorDescriptor onlyOnLanguage(String languageKey);
043
044  /**
045   * List languages this {@link Sensor} work on. Used by the platform to skip execution of the {@link Sensor} when
046   * no file for given languages are present in the project.
047   * Default is to execute sensor for all languages.
048   */
049  SensorDescriptor onlyOnLanguages(String... languageKeys);
050
051  /**
052   * {@link InputFile.Type} this {@link Sensor} work on. Used by the platform to skip execution of the {@link Sensor} when
053   * no file for given type are present in the project.
054   * Default is to execute sensor whatever are the available file types.
055   */
056  SensorDescriptor onlyOnFileType(InputFile.Type type);
057
058  /**
059   * Rule repository this {@link Sensor} create issues for. Used by the platform to skip execution of the {@link Sensor} when
060   * no rule is activated for the given repository.
061   */
062  SensorDescriptor createIssuesForRuleRepository(String... repositoryKey);
063
064  /**
065   * List rule repositories this {@link Sensor} create issues for. Used by the platform to skip execution of the {@link Sensor} when
066   * no rule is activated for the given repositories.
067   */
068  SensorDescriptor createIssuesForRuleRepositories(String... repositoryKeys);
069
070  /**
071   * Property this {@link Sensor} depends on. Used by the platform to skip execution of the {@link Sensor} when
072   * property is not set.
073   */
074  SensorDescriptor requireProperty(String... propertyKey);
075
076  /**
077   * List properties this {@link Sensor} depends on. Used by the platform to skip execution of the {@link Sensor} when
078   * property is not set.
079   */
080  SensorDescriptor requireProperties(String... propertyKeys);
081
082  /**
083   * This sensor should be executed at the project level, instead of per-module.
084   * @since 6.4
085   */
086  SensorDescriptor global();
087}