profile
viewpoint
Tim Kral timkral San Francisco, CA

timkral/appbuilder 0

Library for building Java and Scala applications with micro-services

timkral/docker-maven-plugin 0

Maven plugin for running and creating Docker images

timkral/go-ruleguard 0

Define and run pattern-based custom linting rules.

timkral/golangci-lint 0

Fast linters Runner for Go

timkral/heimdall 0

Build system gatekeeper

timkral/horn 0

Heimdall python client

timkral/mattermost-client 0

Mattermost client using websockets

timkral/oembed 0

The oEmbed Spec

timkral/parent-pom 0

Parent pom file for all Maven-build Spals projects

timkral/spark-dynamodb 0

DynamoDB data source for Apache Spark

PR opened golangci/golangci-lint

Update wrapcheck configuration to include ignoreSignRegexps

This provides an update to the wrapcheck linter configuration to account for a change introduced here - https://github.com/tomarrell/wrapcheck/pull/21

cc: @tomarrell

+8 -2

0 comment

3 changed files

pr created time in 8 days

push eventtimkral/golangci-lint

Tim Kral

commit sha 9fd899cde7d8f4ea5d873165d97882f4e4716ecc

Update wrapcheck configuration to include ignoreSignRegexps

view details

push time in 8 days

issue closedquasilyte/go-ruleguard

Regression on local filter functions?

HI,

I'd like to use a local function as outlined in the Ruleguard by example documentation, but I encountered an error: expected a m method call, found ... . I then tried copying the exact example from the documentation and encountered the same error:

✗ ruleguard -c 1 -rules rcore/lib/linter/rules-services.go ./...
ruleguard: load rules: parse rules file: irconv error: rcore/lib/linter/rules-services.go:34: expected a m method call, found isExported := func(v dsl.Var) bool {
	return v.Text.Matches(`^\p{Lu}`)
}

Is this a feature that's still supported?

closed time in 12 days

timkral

issue commentquasilyte/go-ruleguard

Regression on local filter functions?

Hi @quasilyte ,

Got it, thanks for the response. I'm using version v0.3.13. Ultimately, I'd like to use the feature in the golangci-lint tool so I will wait for a new release and version upgrade there.

-Tim

timkral

comment created time in 12 days

issue commentquasilyte/go-ruleguard

Regression on local filter functions?

I also tried this:

// isExported reports whether bound matcher var
// represents exported Go identifier.
var isExported = func(v dsl.Var) bool {
	return v.Text.Matches(`^\p{Lu}`)
}

func exposedMutex(m dsl.Matcher) {

	// isExported() is more readable than `^\p{Lu}`
	// regular expression itself.

	m.Match(`type $name struct { $*_; sync.Mutex; $*_ }`).
		Where(isExported(m["name"])).
		Report("do not embed sync.Mutex")

	m.Match(`type $name struct { $*_; sync.RWMutex; $*_ }`).
		Where(m["name"].Text.Matches(`^\p{Lu}`)).
		Report("don not embed sync.RWMutex")
}

But got a different error:

✗ ruleguard -c 1 -rules rcore/lib/linter/rules-services.go ./...
ruleguard: load rules: parse rules file: irconv error: rcore/lib/linter/rules-services.go:34: unsupported expr: m["name"] (*ast.IndexExpr)
timkral

comment created time in 12 days

issue openedquasilyte/go-ruleguard

Regression on local filter functions?

HI,

I'd like to use a local function as outlined in the Ruleguard by example documentation, but I encountered an error: expected a m method call, found ... . I then tried copying the exact example from the documentation and encountered the same error:

✗ ruleguard -c 1 -rules rcore/lib/linter/rules-services.go ./...
ruleguard: load rules: parse rules file: irconv error: rcore/lib/linter/rules-services.go:34: expected a m method call, found isExported := func(v dsl.Var) bool {
	return v.Text.Matches(`^\p{Lu}`)
}

Is this a feature that's still supported?

created time in 12 days

fork timkral/mattermost-client

Mattermost client using websockets

fork in 22 days

push eventtimkral/wrapcheck

Tim Kral

commit sha 8a8f52b00b0225b27dad6ed9a19a3b1c95e35e50

Fix docs typo

view details

push time in a month

PR opened tomarrell/wrapcheck

Ignore error signatures via regexp

Hi,

First off, thank you for writing this linter. I can definitely see it catching some critical problems in some of my code bases before they get out to production.

One thing that I ran into, however, was that I have some signatures that I'd like to ignore and follow a distinct pattern, but the pattern isn't uniform enough to use the substring filtering included in the linter. So this change introduces regular expression filtering to give a little bit more flexibility for such cases. It's basically a generalized form of the ignoreSigs configuration. But I kept it separate so as to guarantee backwards compatibility.

I added some tests and it appears to work pretty well. Definitely open to feedback on it.

Thank you! -Tim

+128 -1

0 comment

5 changed files

pr created time in a month

push eventtimkral/wrapcheck

Tim Kral

commit sha 43ca400ac8d958b0c2d2714026805580574df952

Ignore error signatures via regexp

view details

Tim Kral

commit sha 60feb5eea930b8b5e520840779170f0a08c1b0e8

Update docs with new ignoreSigRegexps configuration

view details

push time in a month

fork timkral/wrapcheck

A Go linter to check that errors from external packages are wrapped

https://blog.tomarrell.com/post/introducing_wrapcheck_linter_for_go

fork in a month

issue commentgolangci/golangci-lint

Update support for function matching in Ruleguard

@sebastien-rosset Thank you for the update. Are there plans to release a new version of golangci-lint anytime soon?

timkral

comment created time in a month

PR opened quasilyte/go-ruleguard

Add testing for const iota rules

Related to https://github.com/quasilyte/go-ruleguard/issues/291

@quasilyte You were correct, HEAD appears to properly cover this use case. Test case is included here. Hopefully I included the code in the correct location.

By the way, I really admire your project. I'm using it for custom lint rules in golang to enforce good coding practices. Thank you for your efforts.

Cheers. -Tim

+32 -0

0 comment

2 changed files

pr created time in a month

push eventtimkral/go-ruleguard

Tim Kral

commit sha d2a99cbe56a42cda0348624e81524bae2334aff6

Add testing for const iota rules

view details

push time in a month

push eventtimkral/go-ruleguard

Tim Kral

commit sha 5683f7a39ef102773736f2b5e7f0b97988cbcc4a

Add testing for const iota rules

view details

push time in a month

fork timkral/go-ruleguard

Define and run pattern-based custom linting rules.

https://go-ruleguard.github.io/

fork in a month

issue openedquasilyte/go-ruleguard

Support for matching iota with implicit types

I'm looking to find instances in which we are using the iota feature within golang. There are two general cases that I see available:

  1. Explicit Types
type myType int
const (
  ZERO myType = iota
  ONE
)
  1. Implicit Types
type myType int
const (
  ZERO = iota
  ONE
)

For the first case, I wrote the following rule and it works, no problem:

	m.Match(`$_ $_ = $iota;`).
		Where(m["iota"].Text == "iota").
		At(m["iota"]).
		Report(`...`)

However, I'm having trouble writing a rule that covers the second case. I've made several attempts:

  • $_ $*_ = $iota (I recall that the pattern didn't compile)
  • $_ = $iota (I think because the pattern is compiled as an AssignStmt, not a ValueSpec)
  • const ( $_ = $iota ) (This works but only if there's a single value in the list, as soon as I add more, the pattern doesn't match)
  • const ( $_ = $iota; $*_; ) (this fails the matchNodeList check)

Maybe there's a rule pattern that I haven't considered that would work for that second case. Or maybe it's just not supported by the framework. Any insight here would be greatly appreciated. Thank you!

created time in a month

issue commentgolangci/golangci-lint

Update support for function matching in Ruleguard

Awesome, thanks for the update @quasilyte !

timkral

comment created time in 2 months

issue openedgolangci/golangci-lint

Update support for function matching in Ruleguard

Your feature request related to a problem? Please describe.

I'm trying to write the following rule via Ruleguard in the go-critic linter:

m.Match("func ($_ $_) $methodName($*args) $*_ { $*_; }").Where(m["methodName"].Text.Matches("^test"))

I've tested this rule natively with the latest version of the ruleguard client and it works as expected. However, when using it with the latest version of golangci-lint, the rule does not work.

Describe the solution you'd like.

I believe this just requires an upgrade of the Ruleguard dependency within go-critic. And then a subsequent upgrade of go-critic within golangci-lint.

As of this writing, go-critic uses v0.3.4 of Ruleguard - https://github.com/go-critic/go-critic/pull/1041 . Ruleguard updated it function matching logic in v0.3.5 - https://github.com/quasilyte/go-ruleguard/pull/225

Describe alternatives you've considered.

None.

Additional context.

No response

created time in 2 months

more