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

mulint only detects function calls that are used as statements, not in expressions #6

Open
simonrad opened this issue Nov 15, 2023 · 0 comments

Comments

@simonrad
Copy link

Hi, thank you for writing this linter, as I could not find anything similar anywhere else!

I notice that mulint seems to only traverse function calls that are written as simple statements where the return value is not used. So if a function call is used in an expression then mulint will ignore it.

For example, mulint can detect this deadlock:

type someStruct struct {
  m sync.RWMutex
}

func (s *someStruct) A() {
  s.m.RLock()
  s.B()
  s.m.RUnlock()
}

func (s *someStruct) B() bool {
  s.m.RLock() // This is a recursive lock and it should be detected by this tool
  s.m.RUnlock()
  return true
}

...but not this one:

type someStruct struct {
  m sync.RWMutex
}

func (s *someStruct) A() {
  s.m.RLock()
  v := s.B()           // ***** This is the only difference. *****
  fmt.Println(v)
  s.m.RUnlock()
}

func (s *someStruct) B() bool {
  s.m.RLock() // This is a recursive lock and it should be detected by this tool
  s.m.RUnlock()
  return true
}
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

No branches or pull requests

1 participant