Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAML output issues #307

Open
bufdev opened this issue Nov 5, 2019 · 6 comments
Open

YAML output issues #307

bufdev opened this issue Nov 5, 2019 · 6 comments

Comments

@bufdev
Copy link
Contributor

bufdev commented Nov 5, 2019

Similar to #306, using same commit of both api-linter and googleapis/googleapis.

Issues:

  • Arrays elements printed for files with no problems.
  • I think this invalid YAML but might be wrong - string values printed across multiple lines with various quoting, for example:
 - message: Use the `google.api.field_behavior` annotation instead of " Required.
      CLDR region code of the country/region of the address. This" in the leading
      comments. For example, `string name = 1 [(google.api.field_behavior) = REQUIRED];`.

Unrelated to YAML, but probably not worth filing another issue: api-linter exits with code 0 if there are lint issues. This may be by design though.

$ api-linter google/type/*.proto
- file_path: google/type/calendar_period.proto
  problems: []
- file_path: google/type/color.proto
  problems: []
- file_path: google/type/date.proto
  problems: []
- file_path: google/type/dayofweek.proto
  problems: []
- file_path: google/type/expr.proto
  problems: []
- file_path: google/type/fraction.proto
  problems: []
- file_path: google/type/latlng.proto
  problems: []
- file_path: google/type/money.proto
  problems:
  - message: Fields representing timestamps should use `google.protobuf.Timestamp`.
    location:
      start_position:
        line_number: 43
        column_number: 3
      end_position:
        line_number: 43
        column_number: 19
    rule_id: core::0142::time-field-type
    rule_doc_uri: https://googleapis.github.io/api-linter/rules/core/0142-time-field-type.html
- file_path: google/type/postal_address.proto
  problems:
  - message: Use the `google.api.field_behavior` annotation instead of " Required.
      CLDR region code of the country/region of the address. This" in the leading
      comments. For example, `string name = 1 [(google.api.field_behavior) = REQUIRED];`.
    location:
      start_position:
        line_number: 52
        column_number: 3
      end_position:
        line_number: 52
        column_number: 26
    rule_id: core::0203::required
    rule_doc_uri: https://googleapis.github.io/api-linter/rules/core/0203-required.html
- file_path: google/type/quaternion.proto
  problems: []
- file_path: google/type/timeofday.proto
  problems:
  - message: Fields representing timestamps should use `google.protobuf.Timestamp`.
    location:
      start_position:
        line_number: 41
        column_number: 3
      end_position:
        line_number: 41
        column_number: 21
    rule_id: core::0142::time-field-type
    rule_doc_uri: https://googleapis.github.io/api-linter/rules/core/0142-time-field-type.html
  - message: Fields representing timestamps should use `google.protobuf.Timestamp`.
    location:
      start_position:
        line_number: 44
        column_number: 3
      end_position:
        line_number: 44
        column_number: 19
    rule_id: core::0142::time-field-type
    rule_doc_uri: https://googleapis.github.io/api-linter/rules/core/0142-time-field-type.html
@lukesneeringer
Copy link
Contributor

Personally, I think the linter should exit 1 if it finds errors, and 0 if it finds only warnings.

@rcleveng
Copy link

Also ideally the tool will have some flag like gcc's -Werror to allowing making some warnings into errors

@lukesneeringer
Copy link
Contributor

We have that already!

@apasel422
Copy link
Contributor

Is there anything actionable here?

@lukesneeringer
Copy link
Contributor

The invalid YAML is an issue. For multi-line strings, it should be:

  - message: >
      Use the `google.api.field_behavior` annotation instead of " Required.
      CLDR region code of the country/region of the address. This" in the leading
      comments. For example, `string name = 1 [(google.api.field_behavior) = REQUIRED];`.

The real reason this particular one is happening is because we are preserving a newline from input, but regardless, we should detect \n and do the right thing.

This also might be an issue in whatever YAML output dependency we are using.

@apasel422
Copy link
Contributor

Yeah, I'm surprised that the tests for https://github.com/go-yaml/yaml seem a bit limited in coverage of string encoding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants