Skip to content

Commit

Permalink
Avoid running no-hardcoded-env-urls linter rule in .bicepparam files
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-c-martin committed Mar 13, 2024
1 parent 0c0394b commit e1d3e98
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Bicep.Core.IntegrationTests/ScenarioTests.cs
Expand Up @@ -5724,6 +5724,23 @@ public void Test_Issue12347()
result.ExcludingLinterDiagnostics().Should().NotHaveAnyDiagnostics();
}

// https://github.com/Azure/bicep/issues/13607
[TestMethod]
public void Test_Issue13607()
{
var result = CompilationHelper.CompileParams(
("parameters.bicepparam", """
using 'main.bicep'

param endpoint = 'management.core.windows.net'
"""),
("main.bicep", """
param endpoint string
"""));

result.Should().NotHaveAnyDiagnostics();
}

// https://github.com/Azure/bicep/issues/13250
[TestMethod]
public void Test_Issue13250()
Expand Down
Expand Up @@ -6,6 +6,7 @@
using Bicep.Core.Parsing;
using Bicep.Core.Semantics;
using Bicep.Core.Syntax;
using Bicep.Core.Workspaces;

namespace Bicep.Core.Analyzers.Linter.Rules
{
Expand All @@ -28,6 +29,12 @@ public override string FormatMessage(params object[] values)

public override IEnumerable<IDiagnostic> AnalyzeInternal(SemanticModel model, DiagnosticLevel diagnosticLevel)
{
if (model.SourceFile is BicepParamFile)
{
// The environment() function isn't available for .bicepparam files
return Enumerable.Empty<IDiagnostic>();
}

var disallowedHosts = GetConfigurationValue(model.Configuration.Analyzers, DisallowedHostsKey.ToLowerInvariant(), Array.Empty<string>()).ToImmutableArray();
var excludedHosts = GetConfigurationValue(model.Configuration.Analyzers, ExcludedHostsKey.ToLowerInvariant(), Array.Empty<string>()).ToImmutableArray();

Expand Down

0 comments on commit e1d3e98

Please sign in to comment.