import-no-weak
Since 0.9.0 · In the rulesets: Recommended at warning, Strict at error, All at error
This rule checks whether a Protobuf file uses import weak.
Rule details
A weak import lets a file compile when the imported file is not linked into the program. It is an undocumented feature, supported by few code generators, and its semantics differ between them.
The import-no-weak rule reports Import '<import>' should not be weak for every
import weak statement.
Examples
Good.
syntax = "proto3";
package acme.pets.v1;
import "google/protobuf/timestamp.proto";
message Pet {
string name = 1;
google.protobuf.Timestamp born_at = 2;
}
Bad. The linter reports Import 'google/protobuf/timestamp.proto' should not be weak.
syntax = "proto3";
package acme.pets.v1;
import weak "google/protobuf/timestamp.proto";
message Pet {
string name = 1;
google.protobuf.Timestamp born_at = 2;
}
Turn it off or change its severity
In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.protobuf has the details.
commands:
lint:
protobuf:
rules:
import-no-weak: off