dgryski / semgrep-go

Go rules for semgrep and go-ruleguard
MIT License
460 stars 37 forks source link

Flag comparison of Unix nanotime instead of Before/After? #31

Closed ainar-g closed 3 years ago

ainar-g commented 3 years ago

(Following the discussion in dominikh/go-tools#995.)

Unless the intention of the programmer was to check if the system's wall clock went backwards, code like:

t1.UnixNano() >= t2.UnixNano()

Should be simplified to:

!t1.Before(t2)

Same with other operators.

I think I could write this check myself, but I'm not sure when I will have the time to do it.

dgryski commented 3 years ago

Sounds good to me.