Error caused by incompatible line endings¶
Codacy executes the
git diff command when analyzing new commits and pull requests to identify the lines of code that were changed. Codacy then uses this information to display the issues that were caused by the changes introduced by the commits or pull requests.
If you have files in your repository that use the carriage return (CR) as the line end control character, the command
git diff doesn't correctly identify line endings in the changed files. Because of this, Codacy is unable to use the output of the command and you will see the following error in the your commit or pull request analysis logs:
We found an error caused by incompatible line endings while comparing changes with git diff.
The CR line end control character was used by older Classic Mac OS systems, and for the sake of interoperability it's recommended that you update the line endings in your source code files to use either the control characters:
- LF, if primarily using Unix-like systems such as Linux or the newer macOS operating system
- CRLF, if primarily using the Microsoft Windows operating system
After converting the line endings in your source code files, you may also want to check the following external resources for help on standardizing the line endings on your repositories and how to configure Git to correctly handle line endings:
- What's the recommended way to store files in Git?
- Customizing Git - Formatting and Whitespace
- Configuring Git to handle line endings
- Mind the End of Your Line