test_class.file: sonar-php-plugin/src/test/java/org/sonar/plugins/php/PHPProfileDefinitionTest.java
test_class.identifier: PHPProfileDefinitionTest
test_case.body: @Test
    public void should_contains_security_rules_if_present() {
      // no security rule available
      PhpRules.getRuleKeys().clear();
      assertThat(PHPProfileDefinition.getSecurityRuleKeys()).isEmpty();
  
      // one security rule available
      PhpRules.getRuleKeys().add("S3649");
      assertThat(PHPProfileDefinition.getSecurityRuleKeys()).containsOnly(RuleKey.of("phpsecurity", "S3649"));
    }
test_case.class_method_signature: PHPProfileDefinitionTest.should_contains_security_rules_if_present()
test_case.full_signature: @Test public void should_contains_security_rules_if_present()
test_case.identifier: should_contains_security_rules_if_present
test_case.invocations: clear getRuleKeys isEmpty assertThat getSecurityRuleKeys add getRuleKeys containsOnly assertThat getSecurityRuleKeys of
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void should_contains_security_rules_if_present()
focal_class.declarator: LOG = Loggers.get(PHPProfileDefinition.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = Loggers.get(PHPProfileDefinition.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: SONAR_WAY_PROFILE = "Sonar way"
focal_class.modifier: public static final
focal_class.original_string: public static final String SONAR_WAY_PROFILE = "Sonar way";
focal_class.type: String
focal_class.var_name: SONAR_WAY_PROFILE
focal_class.declarator: SONAR_WAY_PATH = "org/sonar/l10n/php/rules/php/Sonar_way_profile.json"
focal_class.modifier: public static final
focal_class.original_string: public static final String SONAR_WAY_PATH = "org/sonar/l10n/php/rules/php/Sonar_way_profile.json";
focal_class.type: String
focal_class.var_name: SONAR_WAY_PATH
focal_class.declarator: sonarRuntime
focal_class.modifier: private final
focal_class.original_string: private final SonarRuntime sonarRuntime;
focal_class.type: SonarRuntime
focal_class.var_name: sonarRuntime
focal_class.file: sonar-php-plugin/src/main/java/org/sonar/plugins/php/PHPProfileDefinition.java
focal_class.identifier: PHPProfileDefinition
focal_class.interfaces: implements BuiltInQualityProfilesDefinition
focal_class.class_method_signature: PHPProfileDefinition.PHPProfileDefinition(SonarRuntime sonarRuntime)
focal_class.full_signature: public  PHPProfileDefinition(SonarRuntime sonarRuntime)
focal_class.identifier: PHPProfileDefinition
focal_class.modifiers: public
focal_class.parameters: (SonarRuntime sonarRuntime)
focal_class.signature:  PHPProfileDefinition(SonarRuntime sonarRuntime)
focal_class.class_method_signature: PHPProfileDefinition.define(Context context)
focal_class.full_signature: @Override public void define(Context context)
focal_class.identifier: define
focal_class.modifiers: @Override public
focal_class.parameters: (Context context)
focal_class.return: void
focal_class.signature: void define(Context context)
focal_class.class_method_signature: PHPProfileDefinition.getSecurityRuleKeys()
focal_class.full_signature: @VisibleForTesting static Set<RuleKey> getSecurityRuleKeys()
focal_class.identifier: getSecurityRuleKeys
focal_class.modifiers: @VisibleForTesting static
focal_class.parameters: ()
focal_class.return: Set<RuleKey>
focal_class.signature: Set<RuleKey> getSecurityRuleKeys()
focal_class.class_method_signature: PHPProfileDefinition.securityRuleMessage(Exception e)
focal_class.full_signature: private static String securityRuleMessage(Exception e)
focal_class.identifier: securityRuleMessage
focal_class.modifiers: private static
focal_class.parameters: (Exception e)
focal_class.return: String
focal_class.signature: String securityRuleMessage(Exception e)
focal_method.body: @VisibleForTesting
    static Set<RuleKey> getSecurityRuleKeys() {
      try {
  
        Class<?> phpRulesClass = Class.forName("com.sonar.plugins.security.api.PhpRules");
        Method getRuleKeysMethod = phpRulesClass.getMethod("getRuleKeys");
        Set<String> ruleKeys = (Set<String>) getRuleKeysMethod.invoke(null);
        Method getRepositoryKeyMethod = phpRulesClass.getMethod("getRepositoryKey");
        String repositoryKey = (String) getRepositoryKeyMethod.invoke(null);
        return ruleKeys.stream().map(k -> RuleKey.of(repositoryKey, k)).collect(Collectors.toSet());
  
      } catch (ClassNotFoundException e) {
        LOG.debug("com.sonar.plugins.security.api.PhpRules is not found, " + securityRuleMessage(e));
      } catch (NoSuchMethodException e) {
        LOG.debug("Method not found on com.sonar.plugins.security.api.PhpRules, " + securityRuleMessage(e));
      } catch (IllegalAccessException e) {
        LOG.debug("[IllegalAccessException] " + securityRuleMessage(e));
      } catch (InvocationTargetException e) {
        LOG.debug("[InvocationTargetException] " + securityRuleMessage(e));
      }
  
      return new HashSet<>();
    }
focal_method.class_method_signature: PHPProfileDefinition.getSecurityRuleKeys()
focal_method.full_signature: @VisibleForTesting static Set<RuleKey> getSecurityRuleKeys()
focal_method.identifier: getSecurityRuleKeys
focal_method.invocations: forName getMethod invoke getMethod invoke collect map stream of toSet debug securityRuleMessage debug securityRuleMessage debug securityRuleMessage debug securityRuleMessage
focal_method.modifiers: @VisibleForTesting static
focal_method.parameters: ()
focal_method.return: Set<RuleKey>
focal_method.signature: Set<RuleKey> getSecurityRuleKeys()