go-ruleguard: Flaky results: Same rule produces different results (Root cause: regexp not getting parsed)

My rules:

func _(m fluent.Matcher) {
	m.Match(`$s != $t`).Where(m["s"].Const && !m["t"].Const).Suggest(`$t != $s`)
	m.Match(`$s == $t`).Where(m["s"].Const && !m["t"].Const).Suggest(`$t == $s`)
	m.Match(`$s >= $t`).Where(m["s"].Const && !m["t"].Const).Suggest(`$t <= $s`)
	m.Match(`$s <= $t`).Where(m["s"].Const && !m["t"].Const).Suggest(`$t >= $s`)
	m.Match(`$s > $t`).Where(m["s"].Const && !m["t"].Const).Suggest(`$t < $s`)
	m.Match(`$s < $t`).Where(m["s"].Const && !m["t"].Const).Suggest(`$t > $s`)
	m.Match(`nil == $s`).Where(!m["s"].Const).Suggest(`$s == nil`)
	m.Match(`nil != $s`).Where(!m["s"].Const).Suggest(`$s != nil`)
	m.Match(`log.Infof($s)`).Where(m["s"].Const && m["s"].Type.Is(`string`)).Suggest(`log.Info($s)`)
	m.Match(`log.Warnf($s)`).Where(m["s"].Const && m["s"].Type.Is(`string`)).Suggest(`log.Warn($s)`)
	m.Match(`log.Errorf($s)`).Where(m["s"].Const && m["s"].Type.Is(`string`)).Suggest(`log.Error($s)`)
}

Results: Screenshot 2020-07-12 at 11 45 05 AM

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Thank you! This is helpful indeed. It will ease the issue pinpointing significantly.

  1. Nothing special about my go projects, it is a go module which works perfectly fine with go vet/fmt/build/install.

  2. Tried this rules.go:

package gorules

import "github.com/quasilyte/go-ruleguard/dsl/fluent"

func _(m fluent.Matcher) {
	//m.Match(`$s != $t`).Where(m["s"].Const && !m["t"].Const).Suggest(`$t != $s`)
	//m.Match(`$s == $t`).Where(m["s"].Const && !m["t"].Const).Suggest(`$t == $s`)
	//m.Match(`$s >= $t`).Where(m["s"].Const && !m["t"].Const).Suggest(`$t <= $s`)
	//m.Match(`$s <= $t`).Where(m["s"].Const && !m["t"].Const).Suggest(`$t >= $s`)
	//m.Match(`$s > $t`).Where(m["s"].Const && !m["t"].Const).Suggest(`$t < $s`)
	//m.Match(`$s < $t`).Where(m["s"].Const && !m["t"].Const).Suggest(`$t > $s`)
	//m.Match(`nil == $s`).Where(!m["s"].Const).Suggest(`$s == nil`)
	//m.Match(`nil != $s`).Where(!m["s"].Const).Suggest(`$s != nil`)
	m.Match(`log.Infof($s)`).Where(m["s"].Const && m["s"].Type.Is(`string`)).Suggest(`log.Info($s)`)
	//m.Match(`log.Warnf($s)`).Where(m["s"].Const && m["s"].Type.Is(`string`)).Suggest(`log.Warn($s)`)
	//m.Match(`log.Errorf($s)`).Where(m["s"].Const && m["s"].Type.Is(`string`)).Suggest(`log.Error($s)`)
}

Results still same: Screenshot 2020-07-13 at 3 52 01 PM

In order to understand why it happens, I need to reproduce it. I’ll try finding the minimal repro.