Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TFNFR11 - Category: Code Style - Null Comparison Toggle #29

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

neil-yechenwei
Copy link
Contributor

@neil-yechenwei neil-yechenwei commented May 11, 2024

--- PASS: TestNullComparisonToggle/object_variable_exists,_ok (0.00s)
--- PASS: TestNullComparisonToggle/string_local_exists,_ok (0.00s)
--- PASS: TestNullComparisonToggle/string_variable_and_another_condition_exist,_not_ok (0.00s)
--- PASS: TestNullComparisonToggle/string_variable_exists,_not_ok (0.00s)
--- PASS: TestNullComparisonToggle/string_variable_exists_and_the_expression_starts_with_null,not_ok (0.00s)
--- PASS: TestNullComparisonToggle/string_variable_with
!=_exists,_not_ok (0.00s)

Copy link
Member

@lonegunmanb lonegunmanb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @neil-yechenwei !

@matt-FFFFFF Would you please give this rule a review? Thanks!

Copy link
Member

@matt-FFFFFF matt-FFFFFF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments for discussion

}

func (t *NullComparisonToggleRule) Link() string {
return "https://azure.github.io/Azure-Verified-Modules/specs/terraform/#id-tfnfr11---category-code-style---null-comparison-toggle"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no mention of the local workaround in the spec here - do we need to update this as well?

break
}

if v, ok := dynamicVal.(hcl.TraverseAttr); ok && strings.HasSuffix(strings.ToLower(v.Name), "_id") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change this condition to all string values - rather than only those traversals that end with _id?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants