public void Read_Rules()
        {
            rulesMetadataCache.GetRulesConfiguration("c").AllPartialRuleKeys.Should().HaveCount(Active_C_Rules + Inactive_C_Rules);
            rulesMetadataCache.GetRulesConfiguration("cpp").AllPartialRuleKeys.Should().HaveCount(Active_CPP_Rules + Inactive_CPP_Rules);

            // We don't currently support ObjC rules in VS
            rulesMetadataCache.GetRulesConfiguration("objc").Should().BeNull();
        }
        public void Read_Rules()
        {
            var rulesLoader = new RulesLoader(CFamilyHelper.CFamilyFilesDirectory);

            rulesLoader.ReadRulesList().Should().HaveCount(410); // unexpanded list of keys

            rulesMetadataCache.GetRulesConfiguration("c").AllPartialRuleKeys.Should().HaveCount(Active_C_Rules + Inactive_C_Rules);
            rulesMetadataCache.GetRulesConfiguration("cpp").AllPartialRuleKeys.Should().HaveCount(Active_CPP_Rules + Inactive_CPP_Rules);

            // We don't currently support ObjC rules in VS
            rulesMetadataCache.GetRulesConfiguration("objc").Should().BeNull();
        }
        public void GetKeyValueOptionsList_UsingRealEmbeddedRulesJson()
        {
            var sonarWayProvider = new CFamilySonarWayRulesConfigProvider(CFamilyShared.CFamilyFilesDirectory);
            var options          = CFamilyHelper.GetKeyValueOptionsList(sonarWayProvider.GetRulesConfiguration("cpp"));

            // QP option
            CheckHasOption("internal.qualityProfile=");

            // Check a few known rules with parameters
            CheckHasOption("ClassComplexity.maximumClassComplexityThreshold=80");
            CheckHasOption("S1142.max=3");
            CheckHasOption("S1578.format=^[A-Za-z_-][A-Za-z0-9_-]+\\.(c|m|cpp|cc|cxx)$");

            options.Count().Should().Be(38);

            string CheckHasOption(string optionName)
            {
                var matches = options.Where(x => x.StartsWith(optionName, StringComparison.InvariantCulture));

                matches.Count().Should().Be(1);
                return(matches.First());
            }
        }
예제 #4
0
        public void Settings_LanguageKey()
        {
            sonarWayProvider.GetRulesConfiguration("c").LanguageKey.Should().Be("c");
            sonarWayProvider.GetRulesConfiguration("cpp").LanguageKey.Should().Be("cpp");

            // We don't currently support ObjC rules in VS
            sonarWayProvider.GetRulesConfiguration("objc").Should().BeNull();
        }