Skip to content

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'll see an error in the Diff step of your commit or pull request analysis logs:

Viewing the analysis logs

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:

  1. Find the files in your repository that include CR line endings.

    Tip

    On *nix operating systems including macOS, you can use the command file to detect files in your repository that use CR line endings. For example, run the following command on the root of your repository:

    find . -type f -exec file {} \; | grep "CR line"
    
  2. 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

    Tip

    This article on Wikipedia includes examples on how to convert the line endings in your files.

  3. After converting the line endings in your source code files, you may also want to check the following resources for help on standardizing the line endings on your repositories and how to configure Git to correctly handle line endings:

Feedback

Did this page help you?

Thank you for the feedback!

We're sorry to hear that. Please let us know what we can improve.

If you have a question, please ask our community or contact support@codacy.com.

Last modified March 24, 2021