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.

SensorDescriptor.java 3.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.api.batch.sensor;
  21. import java.util.function.Predicate;
  22. import org.sonar.api.batch.fs.InputFile;
  23. import org.sonar.api.config.Configuration;
  24. import org.sonar.api.scanner.sensor.ProjectSensor;
  25. /**
  26. * Describe what a {@link Sensor} is doing. Information may be used by the platform
  27. * to log interesting information or perform some optimization.
  28. * See {@link Sensor#describe(SensorDescriptor)}
  29. * @since 5.1
  30. */
  31. public interface SensorDescriptor {
  32. /**
  33. * Displayable name of the {@link Sensor}. Will be displayed in logs.
  34. */
  35. SensorDescriptor name(String sensorName);
  36. /**
  37. * Language this {@link Sensor} work on. Used by the platform to skip execution of the {@link Sensor} when
  38. * no file for given languages are present in the project.
  39. * Default is to execute sensor for all languages.
  40. */
  41. SensorDescriptor onlyOnLanguage(String languageKey);
  42. /**
  43. * List languages this {@link Sensor} work on. Used by the platform to skip execution of the {@link Sensor} when
  44. * no file for given languages are present in the project.
  45. * Default is to execute sensor for all languages.
  46. */
  47. SensorDescriptor onlyOnLanguages(String... languageKeys);
  48. /**
  49. * {@link InputFile.Type} this {@link Sensor} work on. Used by the platform to skip execution of the {@link Sensor} when
  50. * no file for given type are present in the project.
  51. * Default is to execute sensor whatever are the available file types.
  52. */
  53. SensorDescriptor onlyOnFileType(InputFile.Type type);
  54. /**
  55. * Rule repository this {@link Sensor} create issues for. Used by the platform to skip execution of the {@link Sensor} when
  56. * no rule is activated for the given repository.
  57. */
  58. SensorDescriptor createIssuesForRuleRepository(String... repositoryKey);
  59. /**
  60. * List rule repositories this {@link Sensor} create issues for. Used by the platform to skip execution of the {@link Sensor} when
  61. * no rule is activated for the given repositories.
  62. */
  63. SensorDescriptor createIssuesForRuleRepositories(String... repositoryKeys);
  64. /**
  65. * This sensor should be executed at the project level, instead of per-module.
  66. * @since 6.4
  67. * @deprecated since 7.6 change your {@link Sensor} to a {@link ProjectSensor} instead
  68. */
  69. @Deprecated
  70. SensorDescriptor global();
  71. /**
  72. * Predicate that will be evaluated on current project {@link Configuration} by the platform to decide if execution of the {@link Sensor} should be skipped.
  73. * @since 6.5
  74. */
  75. SensorDescriptor onlyWhenConfiguration(Predicate<Configuration> predicate);
  76. }