001/* 002 * SonarQube, open source software quality management tool. 003 * Copyright (C) 2008-2014 SonarSource 004 * mailto:contact AT sonarsource DOT com 005 * 006 * SonarQube 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 * SonarQube 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; 021 022import org.sonar.api.ExtensionPoint; 023import org.sonar.api.resources.Project; 024 025/** 026 * <p> 027 * A Sensor is invoked once during the analysis of a project. The sensor can parse a flat file, connect to a web server... Sensor are 028 * generally used to add measure at the lowest level of the resource tree. A sensor can access and save measures on the whole tree of 029 * resources. 030 * </p> 031 * 032 * <p> 033 * For example the Cobertura Sensor parses Cobertura report and saves the first-level of measures on resources. 034 * </p> 035 * 036 * <p> 037 * A particular attention should be given to resource exclusion. Sonar already manages exclusions at file level : if you try to save a 038 * measure on a resource that is excluded in the settings, then Sonar will not save the measure. When handling a plugin or an external tool, 039 * you should make sure that exclusions are passed if you are going to get back consolidated data. 040 * </p> 041 * 042 * @since 1.10 043 */ 044@BatchSide 045@ExtensionPoint 046public interface Sensor extends CheckProject { 047 048 /** 049 * Sensors that depend upon Squid must declare the following method : 050 * 051 * <pre> 052 * @DependsUpon 053 * public String dependsUponSquidAnalysis() { 054 * return Sensor.FLAG_SQUID_ANALYSIS; 055 * } 056 * </pre> 057 */ 058 String FLAG_SQUID_ANALYSIS = "squid"; 059 060 /** 061 * The method that is going to be run when the sensor is called 062 * 063 * @param module the module the sensor runs on 064 * @param context the context 065 */ 066 void analyse(Project module, SensorContext context); 067 068}