Giter Site home page Giter Site logo

ckaznocha / protoc-gen-lint Goto Github PK

View Code? Open in Web Editor NEW
280.0 280.0 16.0 775 KB

A plug-in for Google's Protocol Buffers (protobufs) compiler to lint .proto files for style violations.

License: MIT License

Go 100.00%
google-protocol-buffers lint linter plugin protobuf protocol-buffers static-analysis style-linter

protoc-gen-lint's People

Contributors

atetubou avatar ckaznocha avatar dependabot[bot] avatar hvnsweeting avatar nvhbk16k53 avatar rvolosatovs avatar wyattanderson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

protoc-gen-lint's Issues

Inline comment to skip linting

Similar to eslint and others, could we have a comment to skip linting of specific blocks of code?

For instance, in eslint I could do this:

/* eslint-disable */

alert('foo');

/* eslint-enable */

https://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments

Rubocop also has something similar

# rubocop:disable all
[...]
# rubocop:enable all

https://github.com/bbatsov/rubocop/blob/master/manual/configuration.md#disabling-cops-within-source-code

Especially with protocol buffers, changing messages that are already out there is not recommended. Could we expose a way to disable linting via comments? For instance:

// NOTE: the properties start wtih capital letters in order to flawlessly map to an AWS SQSMessage object
// protoc-gen-lint:disable
message SqsMessage {
    string Type = 1;
    string MessageId = 2;
    string TopicArn = 3;
}
// protoc-gen-lint:enable

Status Code 2 return

I tried using your lint on my Proto3 file however it failed. Not sure what the issue could be

C:\main\dlmu\cadaemon-0339.1\include\cagrpc>protoc --lint_out=. CAService.proto
--lint_out: protoc-gen-lint: Plugin failed with status code 2.

I am using the latest x64 protoc using the master branch. My protoc files are used for gRPC. It would be really useful if there was some descriptive text indicating what Status code 2 means

'protoc-gen-lint' is not recognized as an internal or external command, operable program or batch file.

Hello @ckaznocha,

I am locally testing my protobuf file using this linter and it's throwing below errors. Can you help me to resolve the issue?
My protobuf file is in the protoc-gen-lint-master folder.

C:\Repo\protoc-gen-lint-master>protoc --lint_out=. *.proto
'protoc-gen-lint' is not recognized as an internal or external command,
operable program or batch file.
--lint_out: protoc-gen-lint: Plugin failed with status code 1.

I have also tested my proto file with the google style guide rules. I didn't see any of the naming convention rules are executed by this linter. which is not giving any expected errors or suggestions. Can you share more information on it?

Thank you!

Import order

Would be great if the tool could also check if imports are ordered in a consistent way. (Maybe simply alphabetical?)

Getting a status code 126 when running linter

/usr/local/bin/protoc-gen-lint: /usr/local/bin/protoc-gen-lint: cannot execute binary file
--lint_out: protoc-gen-lint: Plugin failed with status code 126.

I am trying to lint one protobuf file and it gives this error every time. I am using this command:

protoc --lint_out=. FILENAME.proto

Option "php_namespace" unknown

I have a project which generates PHP classes from protobuf files and it uses php_namespace option to generate correct class names.
But when I lint it I get this error:

xxx.proto:3:8: Option "php_namespace" unknown.

Line 8 contains

option php_namespace = "Project";

Failing import gives no line and column

In vim, using https://github.com/w0rp/ale, import errors have no line and column which causes the error to be skipped over.

I am not very experienced with linters so IDK if this is normal behavior for that sort of error, what do you think? Is it possible to add a line number of where the import happened?

linux/arm64 builds are x86_64

I noticed that the latest release for arm64 includes an x86_64 binary instead.

mkdir protoc-gen-lint_linux_arm64 && cd protoc-gen-lint_linux_arm64
curl -sSLO https://github.com/ckaznocha/protoc-gen-lint/releases/download/v0.2.3/protoc-gen-lint_linux_arm64.zip
unzip protoc-gen-lint_linux_arm64.zip
file protoc-gen-lint

Output:

protoc-gen-lint_linux_arm64/protoc-gen-lint: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=l37vOoxRha7swXFWPRRu/RTrBCXi-FRWdI_7V03qf/u_DHaiAND98rAROCMkO6/kRU43_m-13vDU_iYkN3Z, not stripped

Building the file manually with GOOS=linux GOARCH=arm64 go build -v . yields:

protoc-gen-lint: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, Go BuildID=w6lhE3eaT2E8M26vW0h9/_p18eAbACZ60qZfyfJ8z/XyBF0tnrYva2bnSbqlQd/lQM-vldy2JbQwkDa63Dy, not stripped

linter gives missing ";" error when "{}" is the problem

When there is a missing {} at the end of the rpc definition, the linter gives the error that ; is missing when that is not really the problem.

service Foo {
    rpc SomeFunc(SomeReq) returns (SomeResp) {}
    rpc GetFoo(BarReq) returns (BarResp)
}

The GetFoo rpc definition will give the missing ; error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.