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

style/prefer-snake-case inconsistent #899

Closed
srenatus opened this issue Jul 5, 2024 · 3 comments · Fixed by #900
Closed

style/prefer-snake-case inconsistent #899

srenatus opened this issue Jul 5, 2024 · 3 comments · Fixed by #900

Comments

@srenatus
Copy link
Member

srenatus commented Jul 5, 2024

this PG

package play

import rego.v1

output["initToggled"] if input.karma > 1

output["userKarma"] := input.karma # line 7

shows me one finding, style/prefer-snake-case on line 7

I would expect it to flag line 5 ("initToggled"), too. Or neither one of them; but having one of the two fail seems a little odd 🤔

@anderseknert
Copy link
Member

Very! I'll take a look. Thanks for reporting that!

@anderseknert
Copy link
Member

Running regal parse p.rego | opa eval -f pretty -I '[h | h := input.rules[_].head]' and looking at the refs, the first one does not come with location attributes, which is why evaluation fails in that case, and the violation remains unreported although it was found.

    "ref": [
      {
        "type": "var",
        "value": "output"
      },
      {
        "type": "string",
        "value": "initToggled"
      }
    ],
    "ref": [
      {
        "location": {
          "col": 1,
          "row": 7,
          "text": "b3V0cHV0"
        },
        "type": "var",
        "value": "output"
      },
      {
        "location": {
          "col": 8,
          "row": 7,
          "text": "InVzZXJLYXJtYSI="
        },
        "type": "string",
        "value": "userKarma"
      }
    ],

OPA bug, I guess? Either way, I'll try to come up with some workaround in the meantime.

@anderseknert
Copy link
Member

OPA issue created: open-policy-agent/opa#6860

anderseknert added a commit that referenced this issue Jul 5, 2024
If ref part is missing loction, default to location of rule.

Fixes #899

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit that referenced this issue Jul 5, 2024
If ref part is missing loction, default to location of rule.

Fixes #899

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit that referenced this issue Jul 5, 2024
If ref part is missing loction, default to location of rule.

Fixes #899

Signed-off-by: Anders Eknert <anders@styra.com>
@anderseknert anderseknert moved this to TODO in Regal Jul 6, 2024
@anderseknert anderseknert moved this from TODO to In Progress in Regal Jul 6, 2024
charlieegan3 pushed a commit that referenced this issue Jul 8, 2024
If ref part is missing loction, default to location of rule.

Fixes #899

Signed-off-by: Anders Eknert <anders@styra.com>
@github-project-automation github-project-automation bot moved this from In Progress to Done in Regal Jul 8, 2024
srenatus pushed a commit to srenatus/regal that referenced this issue Oct 1, 2024
…c#900)

If ref part is missing loction, default to location of rule.

Fixes StyraInc#899

Signed-off-by: Anders Eknert <anders@styra.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants