microsoft / microsoft/PSRule

Realign expressions and assertion methods

Open
#1,539 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature: language
Dominant language
C#
Stars
474
Forks
65
Avg merge
22h 25m
Merged PRs (30d)
26

Description

Discussed in https://github.com/microsoft/PSRule/discussions/904

Originally posted by BernieWhite January 7, 2022
Across expressions (used in YAML and JSON resources) and assertion methods (used in PowerShell resources) there are different names used to equivalent functionality. While terminology differs between programming/ scripting languages we want to make it even easier to understand and author rules.

We should look to realign naming to be ideally the same for expressions and assertion methods.

This discussion proposes the following naming changes.

Expression Assertion method Proposed change
Contains Contains No change
Count Count No change
Equals n/a See note (1)
EndsWith EndsWith No change
Exists HasField Rename assertion method to Exists.
Greater Greater No change
GreaterOrEquals GreaterOrEqual Rename expression to GreaterOrEqual.
HasDefault HasDefaultValue Rename assertion method to HasDefault.
HasSchema HasJsonSchema Rename assertion method to HasSchema.
HasValue n/a See note (1).
In In No change
IsLower IsLower No change
IsString IsString No change
IsUpper IsUpper No change
Less Less No change
LessOrEquals LessOrEqual Rename expression to LessOrEqual.
Match Match No change
NotEquals n/a No change
NotIn NotIn No change
NotMatch NotMatch No change
SetOf SetOf No change
StartsWith StartsWith No change
Subset Subset No change
Version Version No change
n/a FileHeader No change
n/a FilePath No change
n/a HasFields No change
n/a HasFieldValue See note (1)
IsArray IsArray See note (2)
IsBoolean IsBoolean See note (2)
IsDateTime IsDateTime See note (2)
IsInteger IsInteger See note (2)
IsNumeric IsNumeric See note (2)
n/a JsonSchema No change
n/a NotHasField No change
n/a NotNull No change
NotWithinPath NotWithinPath See note (3)
n/a Null No change
n/a NullOrEmpty No change
n/a TypeOf No change
WithinPath WithinPath See note (3)
  • (1) The Equals, HasValue and expression and HasFieldValue are approximate. Also these are not necessarily intuitive.
    • It may be better to introduce Empty, NotEmpty, and Equal across expressions and assertion methods. Then deprecate Equals, HasValue and HasFieldValue.
  • (2) Added in #908.
  • (3) Added in #933.

https://microsoft.github.io/PSRule/v2/concepts/PSRule/en-US/about_PSRule_Expressions/#hasvalue
https://microsoft.github.io/PSRule/v2/concepts/PSRule/en-US/about_PSRule_Expressions/#equals
https://microsoft.github.io/PSRule/v2/concepts/PSRule/en-US/about_PSRule_Assert/#hasfieldvalue

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Discussion #904 and the linked PSRule Expressions and Assertions documentation to understand the proposed terminology changes. The work is done when a naming scheme is decided for equivalent expressions and assertion methods, including whether the approximate value checks should be replaced or deprecated.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.