New Check: XORM #3

Open
opened 2020-05-27 21:13:48 +00:00 by jolheiser · 3 comments
Owner
  • Enforce any function that accepts an Engine to never use x
  • Enforce any function that creates a session to never use x after declaration
* Enforce any function that accepts an `Engine` to never use `x` * Enforce any function that **creates** a session to never use `x` after declaration
jolheiser added this to the v0.2.0 milestone 2020-05-27 21:13:48 +00:00
jolheiser added the
enhancement
label 2020-05-27 21:13:48 +00:00
6543 modified the milestone from v0.2.0 to v0.3.0 2020-07-20 13:17:58 +00:00
6543 added
feature
and removed
enhancement
labels 2020-07-20 13:57:53 +00:00
Owner

Check missed sess.Begin if invoked sess.Commit on the same function.

Check missed `sess.Begin` if invoked `sess.Commit` on the same function.
Owner

if there is a engine in a function ... check if Exported Functions are used witch have a unexported version too, if so ling -> fail

-> https://github.com/go-gitea/gitea/pull/13092

`if there is a engine in a function ... check if Exported Functions are used witch have a unexported version too, if so ling -> fail` -> https://github.com/go-gitea/gitea/pull/13092
Owner

So I just realised that you're being passed an *analysis.Pass object that has the files of the package already parsed as go ast.File s meaning that you don't really need to drop down to calling go list externally - you can get it from each file.

In fact that also means that we could literally find the naughty line of code that caused the import and print it out to the user potentially using ast.Walk.

In any case implementing these checks would require that level of code.

In some ways, dealing with and preventing both of these problems by destroying models.x would likely be less work overall. So as fun as coding with the ast might be that might actually be the better option.

So I just realised that you're being passed an `*analysis.Pass` object that has the files of the package already parsed as go `ast.File` s meaning that you don't really need to drop down to calling `go list` externally - you can get it from each file. In fact that also means that we could literally find the naughty line of code that caused the import and print it out to the user potentially using `ast.Walk`. In any case implementing these checks would require that level of code. In some ways, dealing with and preventing both of these problems by destroying models.x would likely be less work overall. So as fun as coding with the ast might be that might actually be the better option.
Sign in to join this conversation.
No Milestone
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: gitea/gitea-vet#3
No description provided.