forked from chocolatey/choco
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(chocolatey#3000) Update rules to include id and help
This commit updates the rule results and its implemented rules to include an identifier and optionally a url to where more information can be found about the rule. This is done to make it easier in the future to add/update additional functionality in extensions.
- Loading branch information
1 parent
a276706
commit 140155f
Showing
17 changed files
with
3,473 additions
and
3,411 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
112 changes: 56 additions & 56 deletions
112
src/chocolatey/infrastructure.app/rules/EmptyOrInvalidUrlMetadataRule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,56 @@ | ||
// Copyright © 2023-Present Chocolatey Software, Inc | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace chocolatey.infrastructure.app.rules | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using chocolatey.infrastructure.rules; | ||
using NuGet.Packaging; | ||
|
||
internal sealed class EmptyOrInvalidUrlMetadataRule : MetadataRuleBase | ||
{ | ||
public override IEnumerable<RuleResult> validate(NuspecReader reader) | ||
{ | ||
var items = new[] | ||
{ | ||
"projectUrl", | ||
"projectSourceUrl", | ||
"docsUrl", | ||
"bugTrackerUrl", | ||
"mailingListUrl", | ||
"iconUrl", | ||
"licenseUrl" | ||
}; | ||
|
||
foreach (var item in items) | ||
{ | ||
if (has_element(reader, item)) | ||
{ | ||
var value = get_element_value(reader, item); | ||
|
||
if (string.IsNullOrWhiteSpace(value)) | ||
{ | ||
yield return new RuleResult(RuleType.Error, "The {0} element in the package nuspec file cannot be empty.".format_with(item)); | ||
} | ||
else if (!Uri.TryCreate(value, UriKind.Absolute, out _)) | ||
{ | ||
yield return new RuleResult(RuleType.Error, "'{0}' is not a valid URL for the {1} element in the package nuspec file.".format_with(value, item)); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
// Copyright © 2023-Present Chocolatey Software, Inc | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace chocolatey.infrastructure.app.rules | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using chocolatey.infrastructure.rules; | ||
using NuGet.Packaging; | ||
|
||
internal sealed class EmptyOrInvalidUrlMetadataRule : MetadataRuleBase | ||
{ | ||
public override IEnumerable<RuleResult> validate(NuspecReader reader) | ||
{ | ||
var items = new[] | ||
{ | ||
"projectUrl", | ||
"projectSourceUrl", | ||
"docsUrl", | ||
"bugTrackerUrl", | ||
"mailingListUrl", | ||
"iconUrl", | ||
"licenseUrl" | ||
}; | ||
|
||
foreach (var item in items) | ||
{ | ||
if (has_element(reader, item)) | ||
{ | ||
var value = get_element_value(reader, item); | ||
|
||
if (string.IsNullOrWhiteSpace(value)) | ||
{ | ||
yield return new RuleResult(RuleType.Error, RuleIdentifiers.EmptyRequiredElement, "The {0} element in the package nuspec file cannot be empty.".format_with(item)); | ||
} | ||
else if (!Uri.TryCreate(value, UriKind.Absolute, out _)) | ||
{ | ||
yield return new RuleResult(RuleType.Error, RuleIdentifiers.InvalidTypeElement, "'{0}' is not a valid URL for the {1} element in the package nuspec file.".format_with(value, item)); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
64 changes: 32 additions & 32 deletions
64
src/chocolatey/infrastructure.app/rules/FrameWorkReferencesMetadataRule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
// Copyright © 2023-Present Chocolatey Software, Inc | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace chocolatey.infrastructure.app.rules | ||
{ | ||
using System.Collections.Generic; | ||
using chocolatey.infrastructure.rules; | ||
using NuGet.Packaging; | ||
|
||
internal sealed class FrameWorkReferencesMetadataRule : MetadataRuleBase | ||
{ | ||
public override IEnumerable<RuleResult> validate(NuspecReader reader) | ||
{ | ||
if (has_element(reader, "frameworkReferences")) | ||
{ | ||
yield return new RuleResult(RuleType.Error, "<frameworkReferences> elements are not supported in Chocolatey CLI."); | ||
} | ||
} | ||
} | ||
} | ||
// Copyright © 2023-Present Chocolatey Software, Inc | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace chocolatey.infrastructure.app.rules | ||
{ | ||
using System.Collections.Generic; | ||
using chocolatey.infrastructure.rules; | ||
using NuGet.Packaging; | ||
|
||
internal sealed class FrameWorkReferencesMetadataRule : MetadataRuleBase | ||
{ | ||
public override IEnumerable<RuleResult> validate(NuspecReader reader) | ||
{ | ||
if (has_element(reader, "frameworkReferences")) | ||
{ | ||
yield return new RuleResult(RuleType.Error, RuleIdentifiers.UnsupportedElementUsed, "<frameworkReferences> elements are not supported in Chocolatey CLI."); | ||
} | ||
} | ||
} | ||
} |
64 changes: 32 additions & 32 deletions
64
src/chocolatey/infrastructure.app/rules/IconMetadataRule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
// Copyright © 2023-Present Chocolatey Software, Inc | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace chocolatey.infrastructure.app.rules | ||
{ | ||
using System.Collections.Generic; | ||
using chocolatey.infrastructure.rules; | ||
using NuGet.Packaging; | ||
|
||
internal sealed class IconMetadataRule : IMetadataRule | ||
{ | ||
public IEnumerable<RuleResult> validate(NuspecReader reader) | ||
{ | ||
if (!(reader.GetIcon() is null)) | ||
{ | ||
yield return new RuleResult(RuleType.Error, "<icon> elements are not supported in Chocolatey CLI, use <iconUrl> instead."); | ||
} | ||
} | ||
} | ||
} | ||
// Copyright © 2023-Present Chocolatey Software, Inc | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace chocolatey.infrastructure.app.rules | ||
{ | ||
using System.Collections.Generic; | ||
using chocolatey.infrastructure.rules; | ||
using NuGet.Packaging; | ||
|
||
internal sealed class IconMetadataRule : IMetadataRule | ||
{ | ||
public IEnumerable<RuleResult> validate(NuspecReader reader) | ||
{ | ||
if (!(reader.GetIcon() is null)) | ||
{ | ||
yield return new RuleResult(RuleType.Error, RuleIdentifiers.UnsupportedElementUsed, "<icon> elements are not supported in Chocolatey CLI, use <iconUrl> instead."); | ||
} | ||
} | ||
} | ||
} |
66 changes: 33 additions & 33 deletions
66
src/chocolatey/infrastructure.app/rules/LicenseMetadataRule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
// Copyright © 2023-Present Chocolatey Software, Inc | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace chocolatey.infrastructure.app.rules | ||
{ | ||
using System.Collections.Generic; | ||
using System.Runtime.CompilerServices; | ||
using chocolatey.infrastructure.rules; | ||
using NuGet.Packaging; | ||
|
||
internal sealed class LicenseMetadataRule : IMetadataRule | ||
{ | ||
public IEnumerable<RuleResult> validate(NuspecReader reader) | ||
{ | ||
if (!(reader.GetLicenseMetadata() is null)) | ||
{ | ||
yield return new RuleResult(RuleType.Error, "<license> elements are not supported in Chocolatey CLI, use <licenseUrl> instead."); | ||
} | ||
} | ||
} | ||
} | ||
// Copyright © 2023-Present Chocolatey Software, Inc | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace chocolatey.infrastructure.app.rules | ||
{ | ||
using System.Collections.Generic; | ||
using System.Runtime.CompilerServices; | ||
using chocolatey.infrastructure.rules; | ||
using NuGet.Packaging; | ||
|
||
internal sealed class LicenseMetadataRule : IMetadataRule | ||
{ | ||
public IEnumerable<RuleResult> validate(NuspecReader reader) | ||
{ | ||
if (!(reader.GetLicenseMetadata() is null)) | ||
{ | ||
yield return new RuleResult(RuleType.Error, RuleIdentifiers.UnsupportedElementUsed, "<license> elements are not supported in Chocolatey CLI, use <licenseUrl> instead."); | ||
} | ||
} | ||
} | ||
} |
64 changes: 32 additions & 32 deletions
64
src/chocolatey/infrastructure.app/rules/PackageTypesMetadataRule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
// Copyright © 2023-Present Chocolatey Software, Inc | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace chocolatey.infrastructure.app.rules | ||
{ | ||
using System.Collections.Generic; | ||
using chocolatey.infrastructure.rules; | ||
using NuGet.Packaging; | ||
|
||
internal sealed class PackageTypesMetadataRule : MetadataRuleBase | ||
{ | ||
public override IEnumerable<RuleResult> validate(NuspecReader reader) | ||
{ | ||
if (has_element(reader, "packageTypes")) | ||
{ | ||
yield return new RuleResult(RuleType.Error, "<packageTypes> elements are not supported in Chocolatey CLI."); | ||
} | ||
} | ||
} | ||
} | ||
// Copyright © 2023-Present Chocolatey Software, Inc | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace chocolatey.infrastructure.app.rules | ||
{ | ||
using System.Collections.Generic; | ||
using chocolatey.infrastructure.rules; | ||
using NuGet.Packaging; | ||
|
||
internal sealed class PackageTypesMetadataRule : MetadataRuleBase | ||
{ | ||
public override IEnumerable<RuleResult> validate(NuspecReader reader) | ||
{ | ||
if (has_element(reader, "packageTypes")) | ||
{ | ||
yield return new RuleResult(RuleType.Error, RuleIdentifiers.UnsupportedElementUsed, "<packageTypes> elements are not supported in Chocolatey CLI."); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.