Esempio n. 1
0
        public void GetHelpLink_VisualBasic()
        {
            var helpLink = DiagnosticDescriptorBuilder
                           .GetHelpLink(vbnet.SonarAnalyzer.RspecStrings.ResourceManager, "S1234");

            helpLink.Should().Be("https://rules.sonarsource.com/vbnet/RSPEC-1234");
        }
Esempio n. 2
0
        public void GetHelpLink_CSharp()
        {
            var helpLink = DiagnosticDescriptorBuilder
                           .GetHelpLink(csharp.SonarAnalyzer.RspecStrings.ResourceManager, "S1234");

            helpLink.Should().Be("https://rules.sonarsource.com/csharp/RSPEC-1234");
        }
Esempio n. 3
0
 protected PubliclyWritableDirectoriesBase(IAnalyzerConfiguration configuration, ResourceManager rspecResources) : base(configuration)
 {
     rule                 = DiagnosticDescriptorBuilder.GetDescriptor(DiagnosticId, MessageFormat, rspecResources).WithNotConfigurable();
     linuxDirectories     = new Regex($@"^({linuxDirs.JoinStr("|", x => Regex.Escape(x))})(\/|$)", RegexOptions.Compiled);
     macDirectories       = new Regex($@"^({macDirs.JoinStr("|", x => Regex.Escape(x))})(\/|$)", WindowsAndUnixOptions);
     environmentVariables = new Regex($@"^%({InsecureEnvironmentVariables.JoinStr("|")})%([\\\/]|$)", WindowsAndUnixOptions);
 }
        public void GetUtilityDescriptor_Should_Contain_NotConfigurable_CustomTag()
        {
            var result = DiagnosticDescriptorBuilder.GetUtilityDescriptor("Foo", "");

#if DEBUG
            result.CustomTags.Should().NotContain(WellKnownDiagnosticTags.NotConfigurable);
#else
            result.CustomTags.Should().Contain(WellKnownDiagnosticTags.NotConfigurable);
#endif
        }
Esempio n. 5
0
        public void GetDescriptor_SetsIsEnabledByDefaultToTrue()
        {
            DiagnosticDescriptorBuilder.GetDescriptor("S100", "", csharp.SonarAnalyzer.RspecStrings.ResourceManager)
            .IsEnabledByDefault
            .Should().BeTrue();

            DiagnosticDescriptorBuilder.GetDescriptor("S100", "", SonarAnalyzer.Common.IdeVisibility.Hidden,
                                                      csharp.SonarAnalyzer.RspecStrings.ResourceManager)
            .IsEnabledByDefault
            .Should().BeTrue();
        }
Esempio n. 6
0
        public void GetDescriptor_WhenIsActivatedByDefaultAndIdeVisibilityNotHidden_HasOnlySonarWayAndLanguageTags()
        {
            // Arrange
            var diagnosticId          = "foo";
            var mockedResourceManager = CreateMockedResourceManager(diagnosticId, true);

            // Act
            var result = DiagnosticDescriptorBuilder.GetDescriptor(diagnosticId, "", mockedResourceManager);

            // Assert
            result.CustomTags.Should().OnlyContain(DiagnosticTagsHelper.SonarWayTag, LanguageValue);
        }
Esempio n. 7
0
        public void GetDescriptor_WhenIsNotActivatedByDefaultAndIdeVisibilityIsHidden_HasOnlyUnnecessaryAndLanguageTags()
        {
            // Arrange
            var diagnosticId          = "foo";
            var mockedResourceManager = CreateMockedResourceManager(diagnosticId, false);

            // Act
            var result = DiagnosticDescriptorBuilder.GetDescriptor(diagnosticId, "", IdeVisibility.Hidden, mockedResourceManager);

            // Assert
            result.CustomTags.Should().OnlyContain(WellKnownDiagnosticTags.Unnecessary, LanguageValue);
        }
Esempio n. 8
0
        public void GetDescriptor_WhenIsNotActivatedByDefaultAndIdeVisibilityNotHidden_ContainsOnlyLanguage()
        {
            // Arrange
            var diagnosticId          = "foo";
            var mockedResourceManager = CreateMockedResourceManager(diagnosticId, false);

            // Act
            var result = DiagnosticDescriptorBuilder.GetDescriptor(diagnosticId, "", mockedResourceManager);

            // Assert
            result.CustomTags.Should().OnlyContain(LanguageValue);
        }
Esempio n. 9
0
        public void GetUtilityDescriptor_Should_Contain_NotConfigurable_CustomTag_SourceScope_Specified()
        {
            foreach (SourceScope sourceScope in Enum.GetValues(typeof(SourceScope)))
            {
                // Arrange
                // Act
                var result = DiagnosticDescriptorBuilder.GetUtilityDescriptor("Foo", "", sourceScope);

                // Assert
#if DEBUG
                result.CustomTags.Should().NotContain(WellKnownDiagnosticTags.NotConfigurable);
#else
                result.CustomTags.Should().Contain(WellKnownDiagnosticTags.NotConfigurable);
#endif
            }
        }
Esempio n. 10
0
        public void GetDescriptor_SetsIsEnabledByDefaultToGivenValue()
        {
            // Arrange
            var diagnosticId          = "FooBar";
            var mockedResourceManager = CreateMockedResourceManager(diagnosticId, isActivatedByDefault: true);

            DiagnosticDescriptorBuilder.GetDescriptor(diagnosticId, "", mockedResourceManager, true)
            .IsEnabledByDefault
            .Should()
            .BeTrue();

            DiagnosticDescriptorBuilder.GetDescriptor(diagnosticId, "", mockedResourceManager, false)
            .IsEnabledByDefault
            .Should()
            .BeFalse();

            DiagnosticDescriptorBuilder.GetDescriptor(diagnosticId, "", mockedResourceManager)
            .IsEnabledByDefault
            .Should()
            .BeTrue();
        }
Esempio n. 11
0
 protected JwtSignedBase(System.Resources.ResourceManager rspecResources)
 {
     verifyingRule = DiagnosticDescriptorBuilder
                     .GetDescriptor(DiagnosticId, string.Format(MessageFormat, MessageVerifying), rspecResources)
                     .WithNotConfigurable();
 }
Esempio n. 12
0
 protected PropertiesAccessCorrectFieldBase(System.Resources.ResourceManager rspecResources)
 {
     rule = DiagnosticDescriptorBuilder.GetDescriptor(DiagnosticId, MessageFormat, rspecResources);
 }
 protected MethodOverloadsShouldBeGroupedBase(System.Resources.ResourceManager resources)
 {
     rule = DiagnosticDescriptorBuilder.GetDescriptor(DiagnosticId, MessageFormat, resources);
 }
Esempio n. 14
0
 protected ProvideDeserializationMethodsForOptionalFieldsBase()
 {
     rule = DiagnosticDescriptorBuilder.GetDescriptor(DiagnosticId, MessageFormat, Language.RspecResources);
 }
 protected $DiagnosticClassName$Base() =>
 Rule = DiagnosticDescriptorBuilder.GetDescriptor(DiagnosticId, MessageFormat, Language.RspecResources);
 public MarkAssemblyWithComVisibleAttributeBase(System.Resources.ResourceManager rspecResources)
     : base(DiagnosticDescriptorBuilder.GetDescriptor(DiagnosticId, MessageFormat, rspecResources))
 {
 }
 protected $DiagnosticClassName$Base(System.Resources.ResourceManager rspecResources) =>
 Rule = DiagnosticDescriptorBuilder.GetDescriptor(DiagnosticId, MessageFormat, rspecResources);
Esempio n. 18
0
 protected HardcodedIpAddressBase(IAnalyzerConfiguration analyzerConfiguration, System.Resources.ResourceManager rspecResources) : base(analyzerConfiguration)
 {
     rule = DiagnosticDescriptorBuilder.GetDescriptor(DiagnosticId, MessageFormat, rspecResources).WithNotConfigurable();
 }
Esempio n. 19
0
 protected ParameterAssignedToBase(System.Resources.ResourceManager rspecResources)
 {
     rule = DiagnosticDescriptorBuilder.GetDescriptor(DiagnosticId, MessageFormat, rspecResources);
 }
Esempio n. 20
0
 protected SelfAssignmentBase(System.Resources.ResourceManager rspecResources)
 {
     this.rule = DiagnosticDescriptorBuilder.GetDescriptor(DiagnosticId, MessageFormat, rspecResources);
 }
Esempio n. 21
0
 protected MarkAssemblyWithAssemblyVersionAttributeBase(System.Resources.ResourceManager rspecResources)
     : base(DiagnosticDescriptorBuilder.GetDescriptor(DiagnosticId, MessageFormat, rspecResources))
 {
 }
Esempio n. 22
0
 protected CertificateValidationCheckBase(System.Resources.ResourceManager rspecResources)
 {
     rule = DiagnosticDescriptorBuilder.GetDescriptor(DiagnosticId, MessageFormat, rspecResources);
 }
Esempio n. 23
0
 protected DisablingRequestValidationBase(System.Resources.ResourceManager rspecResources, IAnalyzerConfiguration configuration)
 {
     rule = DiagnosticDescriptorBuilder.GetDescriptor(DiagnosticId, MessageFormat, rspecResources).WithNotConfigurable();
     this.configuration = configuration;
 }
Esempio n. 24
0
 protected GotoStatementBase(System.Resources.ResourceManager rspecResources)
 {
     rule = DiagnosticDescriptorBuilder.GetDescriptor(DiagnosticId, string.Format(MessageFormat, GoToLabel), rspecResources);
 }
Esempio n. 25
0
 protected FieldShadowsParentFieldBase(System.Resources.ResourceManager rspecResources)
 {
     s2387 = DiagnosticDescriptorBuilder.GetDescriptor(S2387DiagnosticId, S2387MessageFormat, rspecResources);
     s4025 = DiagnosticDescriptorBuilder.GetDescriptor(S4025DiagnosticId, S4025MessageFormat, rspecResources);
 }
 protected RequestsWithExcessiveLengthBase(IAnalyzerConfiguration analyzerConfiguration)
 {
     rule = DiagnosticDescriptorBuilder.GetDescriptor(DiagnosticId, MessageFormat, Language.RspecResources).WithNotConfigurable();
     this.analyzerConfiguration = analyzerConfiguration;
 }