Skip to content

Scan nested expressions#1504

Merged
anderseknert merged 1 commit intomainfrom
nested-expressions
Apr 28, 2025
Merged

Scan nested expressions#1504
anderseknert merged 1 commit intomainfrom
nested-expressions

Conversation

@anderseknert
Copy link
Copy Markdown
Member

A few of the first Regal rules only ever checked the top level of a body, and would not traverse into e.g. comprehensions or every bodies. This has been annoying for long, and while doing this properly is certainly more expensive (+2 million allocs) I think we can afford that at this point in order to prioritize correctness. May very well be that many will have Regal find "new" issues in the next version due to this.

We now also separate ast.found.references and ast.found.calls instead of collecting both under ast.found.references. This too comes at a cost, but makes it much more obvious what our code is doing, and we can now afford prioritizing that too.

Fixes #82

@anderseknert anderseknert force-pushed the nested-expressions branch 2 times, most recently from 7253f37 to 56b10fe Compare April 28, 2025 07:57
A few of the first Regal rules only ever checked the top level of
a body, and would not traverse into e.g. comprehensions or every
bodies. This has been annoying for long, and while doing this
properly is certainly more expensive (+2 million allocs) I think
we can afford that at this point in order to prioritize correctness.
May very well be that many will have Regal find "new" issues in the
next version due to this.

Also:
- We now also separate ast.found.references and ast.found.calls. This
  too comes at a cost, but makes it much more obvious what our code is
  doing, and we can now afforc prioritizing that too.
- Improve `narrow-argument` rule to also take array indices into account
  for narrowing (i.e. only `arr[1].value[0]` referenced)
- Fix new golangci-lint rule that says public functions should be above
  private ones.

Fixes #82

Signed-off-by: Anders Eknert <anders@styra.com>
Copy link
Copy Markdown
Contributor

@srenatus srenatus left a comment

Choose a reason for hiding this comment

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

The internal/lsp code moves seem unrelated, but OK.

@anderseknert anderseknert merged commit 4edddb2 into main Apr 28, 2025
5 checks passed
@anderseknert anderseknert deleted the nested-expressions branch April 28, 2025 08:21
@anderseknert
Copy link
Copy Markdown
Member Author

@srenatus yeah, sorry about that... the commit message is a little more detailed 35eafec

But even that did not cover everything here as I took the liberty of fixing things here and there that were not directly covered by existing issues.

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.

Rule: constant conditions

2 participants