codeclimate / codeclimate-sonar-python

GNU Affero General Public License v3.0
4 stars 6 forks source link

Should lint ignore png files by default? #4

Open taliaga opened 5 years ago

taliaga commented 5 years ago

Hi,

Using codeclimate I came across an error (see message below) that won't let me run the rest of the code-climate suite.

I tend to think .png files should be excluded by default, but I'm not sure if this should be configured in this repo or in a different one. Wdyt?

We had trouble running the sonar-python engine.

The engine's output shown below may indicate the cause of the error.

If not, please contact us so we can investigate further.

INFO: Java 1.8.0_111-internal Oracle Corporation (64-bit)
INFO: Linux 4.4.0-1061-aws amd64
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/src/app/build/libs/sonarlint-core-2.17.0.899.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/src/app/build/libs/sonarlint-cli-2.1.0.566.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
INFO: Index files
INFO: Invalid character encountered in file '/code/src/geocoding/slf/slf-components.png' at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
INFO: Invalid character encountered in file '/code/docs/manuals.ja/rsrc/architecture.png' at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
INFO: Invalid character encountered in file '/code/docs/manuals.ja/rsrc/graph_example.png' at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 1.011s
INFO: Final Memory: 4M/232M
INFO: ------------------------------------------------------------------------
ERROR: Error executing SonarLint
ERROR: Failed to open a stream on file: /code/docs/manuals.ja/rsrc/crate_datasource.png
ERROR: Caused by: /code/docs/manuals.ja/rsrc/crate_datasource.png
ERROR: 
ERROR: To see the full stack trace of the errors, re-run SonarLint with the -e switch.
ERROR: Re-run SonarLint using the -X switch to enable full debug logging.

Cheers!

wfleming commented 5 years ago

This looks like an issue with https://github.com/codeclimate/codeclimate-ss-analyzer-wrapper: that repo defines the wrapper code that is used in our various sonar plugins. It is responsible for walking the various files permitted to be analyzed and then handing them off the Sonar implementation. The sonar implementation then decides if it's a file it actually cares about, but it looks like it probably doesn't handle binary files correctly.

I don't know when we might be able to fix this, but pull requests on that repo are welcome if you're interested in looking into it. I think the logic to expand would be somewhere in https://github.com/codeclimate/codeclimate-ss-analyzer-wrapper/tree/master/src/main/java/cc/files.

Or if you'd rather just work around the issue you can adjust your Code Climate configuration to exclude pngs files.

We don't exclude pngs (or almost any file extension) by default because our default excludes are global, and we wouldn't want to preclude support for a new plugin that analyzed that file type. (E.g. I could imagine a plugin that might analyze pngs to ensure they were optimized/small enough.)