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

Text file considered as binary #23

Closed
mhagnumdw opened this issue May 2, 2018 · 4 comments
Closed

Text file considered as binary #23

mhagnumdw opened this issue May 2, 2018 · 4 comments

Comments

@mhagnumdw
Copy link

The attached text file is considered as binary, resulting in build failure. If you remove the accented characters the problem will disappear.

simplelogger.properties.zip

Command
mvn org.ec4j.maven:editorconfig-maven-plugin:check -Deditorconfig.excludes="db/**,log/**"

Maven output

[ERROR] Failed to execute goal org.ec4j.maven:editorconfig-maven-plugin:0.0.5:check (default-cli) on project xyz: 
[ERROR] 
[ERROR] Could not read /home/user/ambiente/workspace/xyz/src/main/resources/simplelogger.properties. This may mean that it is a binary file and you should exclude it from editorconfig processing.
[ERROR] 
[ERROR] : Input length = 1
[ERROR] -> [Help 1]

Maven output with relevant stacktrace

Caused by: java.nio.charset.MalformedInputException: Input length = 1
	at java.nio.charset.CoderResult.throwException(CoderResult.java:281)
	at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:339)
	at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
	at java.io.InputStreamReader.read(InputStreamReader.java:184)
	at java.io.BufferedReader.fill(BufferedReader.java:161)
	at java.io.BufferedReader.read(BufferedReader.java:182)
	at org.ec4j.maven.lint.api.LineReader$DelegatingLineReader.read(LineReader.java:66)
	at org.ec4j.maven.lint.api.LineReader$DelegatingLineReader.readLine(LineReader.java:124)
	at org.ec4j.maven.linters.TextLinter.process(TextLinter.java:156)
	... 23 more
@ppalaga
Copy link
Collaborator

ppalaga commented May 2, 2018

Thanks for the report. Clearly, there is a mismatch between the encoding of the file and the encoding the plugin is using. Could you please provide the following info to be able to tell if this is a bug or just a misconfiguration?

(1) What is the encoding of the file?

(2) Have you set the encoding at the Maven level for all files, via editorconfig.encoding or project.build.sourceEncoding property?

(3) Have you set charset in any of the relevant .editorconfig files?

@mhagnumdw
Copy link
Author

Hi!

(1) What is the encoding of the file?

  • With linux file -i: text/plain; charset=iso-8859-1
  • With Sublime Text 3: Western (Windows 1252) Unix
  • With Eclipse: ISO-8859-1
  • With Geany: ISO-8859-1
  • With Notepadqq: UNIX / OX S ISO-8859-1

(2) Have you set the encoding at the Maven level for all files, via editorconfig.encoding or project.build.sourceEncoding property?

  • My pom.xml contains <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  • I did not set the editorconfig.encoding property (My maven command line was just as it is in the first post)

(3) Have you set charset in any of the relevant .editorconfig files?

Yes. Below is my .editorconfig file (I only have one in the root directory of the app):

root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2

@ppalaga
Copy link
Collaborator

ppalaga commented May 2, 2018

Thanks, let me try to reproduce it.

ppalaga added a commit to ppalaga/editorconfig-maven-plugin that referenced this issue May 2, 2018
@ppalaga
Copy link
Collaborator

ppalaga commented May 2, 2018

Yes, this is definitely a misconfiguration. You instruct the plugin to handle the file as UTF-8 but in reality the file is ISO-8859-1. It will work if you add something like the following to the bottom of your .editorconfig file:

[*.properties]
charset = iso-8859-1

@ppalaga ppalaga closed this as completed May 2, 2018
ppalaga added a commit to ppalaga/editorconfig-maven-plugin that referenced this issue May 2, 2018
ppalaga added a commit that referenced this issue May 2, 2018
Add a test for .editorconfig charset property; resolves #23
ppalaga added a commit to ppalaga/editorconfig-maven-plugin that referenced this issue Oct 4, 2018
ppalaga added a commit to ppalaga/editorconfig-maven-plugin that referenced this issue Oct 4, 2018
Add a test for .editorconfig charset property; resolves ec4j#23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants