class RubyPlugin implements Plugin {

  @Override
  public void define(Context context) {
    context.addExtensions(
      RubyLanguage.class,
      RubySensor.class,
      RubyProfileDefinition.class,
      RubyRulesDefinition.class);

    boolean externalIssuesSupported = context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(7, 2));

    if (context.getRuntime().getProduct() != SonarProduct.SONARLINT) {
      context.addExtensions(
        new RuboCopRulesDefinition(externalIssuesSupported),
        RuboCopSensor.class,
        SimpleCovSensor.class,

        PropertyDefinition.builder(RUBY_FILE_SUFFIXES_KEY)
          .defaultValue(RUBY_FILE_SUFFIXES_DEFAULT_VALUE)
          .name("File Suffixes")
          .description("List of suffixes for files to analyze.")
          .subCategory(GENERAL)
          .category(RUBY_CATEGORY)
          .multiValues(true)
          .onQualifiers(Qualifiers.PROJECT)
          .build(),

        PropertyDefinition.builder(REPORT_PATHS_KEY)
          .defaultValue(REPORT_PATHS_DEFAULT_VALUE)
          .name("Path to coverage report(s)")
          .description("Path to coverage report files (.resultset.json) generated by SimpleCov. The path may be absolute or relative to the project base directory.")
          .category(RUBY_CATEGORY)
          .subCategory(TEST_COVERAGE_SUBCATEGORY)
          .onQualifiers(Qualifiers.PROJECT)
          .multiValues(true)
          .build()
      );

      if (externalIssuesSupported) {
        context.addExtension(
          PropertyDefinition.builder(RuboCopSensor.REPORT_PROPERTY_KEY)
            .name("RuboCop Report Files")
            .description("Paths (absolute or relative) to json files with RuboCop issues.")
            .category(EXTERNAL_ANALYZERS_CATEGORY)
            .subCategory(RUBY_CATEGORY)
            .onQualifiers(Qualifiers.PROJECT)
            .multiValues(true)
            .build());
      }
    }
  }

}