-
Notifications
You must be signed in to change notification settings - Fork 19
fix: resolve conflicting edits for type assertion and error comparison (fixes #100) #104
base: main
Are you sure you want to change the base?
Conversation
fixes polyfloyd#100) - Implement conflict resolution when both type assertion and error comparison linting rules apply to the same line - Add support for else-if statement transformations using errors.As and errors.Is - Generate combined diagnostics with unified suggested fixes Signed-off-by: Kemal Akkoyun <[email protected]>
|
Testing this PR on the same code as in the error description, the comment lines were dropped. - } else if e, ok := err.(*os.PathError); ok && e.Err == syscall.ESRCH {
- // If the process exits while reading its /proc/$PID/maps, the kernel will
- // return ESRCH. Handle it as if the process did not exist.
- pm.mappingStats.errProcESRCH.Add(1)
+ } else {
+ e := &os.PathError{}
+ if errors.As(err, &e) && errors.Is(e.Err, syscall.ESRCH) {
+ pm.mappingStats.errProcESRCH.Add(1)
+ }
}Also (maybe a different issue), with the following change, the - if n == 0 || (err != nil && err != io.EOF) {
+ if n == 0 || (err != nil && !errors.Is(err, io.EOF)) {Let me know if this is unrelated and I'll open another issue. |
Good catch. I have to make sure we preserve the comments (hard with stdlib). I will think ways to simplify the implementation. It is hard to rewrite control flow statements. |
0353982 to
69bbbfc
Compare
Signed-off-by: Kemal Akkoyun <[email protected]>
69bbbfc to
81371b5
Compare
|
Hey @kakkoyun, is this still considered a draft? Or is this getting to a state where it can be reviewed? |
It is technically in a reviewable state. I can mark it ready. However, I want to do some clean up and refactoring. What would you prefer? Merge this and iterate or have the refactoring in this PR? |
|
Yes, please include the refactoring in this PR 🙏 |
Signed-off-by: Kemal Akkoyun [email protected]