apigee / apigeelint

Static code analysis for Apigee proxy bundles to encourage API developers to use best practices and avoid anti-patterns.
Apache License 2.0
93 stars 71 forks source link

There should be an easy way to "Suppress Warnings" via annotations in a file within a bundle #444

Closed DinoChiesa closed 2 months ago

DinoChiesa commented 5 months ago

The apigeelint cli allows users to exclude plugins with the -e option (--excluded) .

Also apigeelint will now read configuration options including the option to exclude specific plugins, from an .apigeelintrc file which it will look for in a series of locations.

But there is no way to specify a desire to ignore particular warnings or errors, just within a particular file.

As an example, maybe I have a Condition statement that is "too complex" according to the plugin. But it's known to be good, and I want to disable the warning for that particular line, that particular Condition statement. Or I know about the recommendation to use TargetServers but I don't want to be warned about that for my TargetEndpoint that uses a direct URL connection.

This would be analogous to Java's SuppressWarnings annotation, or to the "disable" comment you can add to a shell script to disable some shellcheck warnings.

# shellcheck disable=SC2046,SC2162
DinoChiesa commented 5 months ago

I am thinking something like

<TargetEndpoint name="target-1">
  ...
  <HTTPTargetConnection>
    <!-- apigeelint disable=TD004 -->
    <SSLInfo>
      <Enabled>true</Enabled>
      <IgnoreValidationErrors>false</IgnoreValidationErrors>
    </SSLInfo>

    <!-- apigeelint disable=TD002 -->
    <URL>https://my-target-endpoint.cymbalgroup.com</URL>
  </HTTPTargetConnection>
</TargetEndpoint>

Does anyone else think this is a good idea?

ssvaidyanathan commented 5 months ago

I like it.. follows the general theme of other linters like JSHint, etc

DinoChiesa commented 2 months ago

This has now been implemented. A release with this feature is pending.