Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/UrbanCompass/thriftlint
An extensible linter for Thrift
https://github.com/UrbanCompass/thriftlint
golang linter thrift thrift-lint
Last synced: 3 months ago
JSON representation
An extensible linter for Thrift
- Host: GitHub
- URL: https://github.com/UrbanCompass/thriftlint
- Owner: UrbanCompass
- License: mit
- Created: 2017-01-11T00:19:43.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-17T00:35:42.000Z (almost 6 years ago)
- Last Synced: 2024-06-20T17:43:36.399Z (5 months ago)
- Topics: golang, linter, thrift, thrift-lint
- Language: Go
- Size: 17.6 KB
- Stars: 40
- Watchers: 394
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# An extensible linter for Thrift [![](https://godoc.org/github.com/UrbanCompass/thriftlint?status.svg)](http://godoc.org/github.com/UrbanCompass/thriftlint)
This is an extensible linter for [Thrift](https://thrift.apache.org/). It
includes a set of common lint checks, but allows for both customisation of those
checks, and creation of new ones by implementing the
[Check](https://godoc.org/github.com/UrbanCompass/thriftlint#Check) interface.For an example of how to build your own linter utility, please refer to the
[thrift-lint source](https://github.com/UrbanCompass/thriftlint/tree/master/cmd/thrift-lint).## Example checker
Here is an example of a checker utilising the `MakeCheck()` convenience
function to ensure that fields are present in the file in the same order as
their field numbers:```go
func CheckStructFieldOrder() thriftlint.Check {
return thriftlint.MakeCheck("field.order", func(s *parser.Struct) (messages thriftlint.Messages) {
fields := sortedFields(s.Fields)
sort.Sort(fields)
for i := 0; i < len(fields)-1; i++ {
a := fields[i]
b := fields[i+1]
if a.Pos.Line > b.Pos.Line {
messages.Warning(fields[i], "field %d and %d are out of order", a.ID, b.ID)
}
}
return
})
}
```## thrift-lint tool
A binary is included that can be used to perform basic linting with the builtin checks:
```
$ go get github.com/UrbanCompass/thriftlint/cmd/thrift-lint
$ thrift-lint --help
usage: thrift-lint [] ...A linter for Thrift.
For details, please refer to https://github.com/UrbanCompass/thriftlint
Flags:
--help Show context-sensitive help (also try --help-long
and --help-man).
-I, --include=DIR ... Include directories to search.
--debug Enable debug logging.
--disable=LINTER ... Linters to disable.
--list List linter checks.
--errors Only show errors.Args:
Thrift sources to lint.
```