Do not raise Drupal.Files.EndFileNewline.NoneFound for empty files

Created on 16 October 2024, 6 months ago

Problem/Motivation

An empty file will trigger Drupal.Files.EndFileNewline.NoneFound, "Expected 1 newline at end of file; 0 found". phpcbf will attempt to fix it by adding a newline, but this creates the issue of whitespace at the top of the file.

Steps to reproduce

Run phpcs on an empty file using the Drupal standard.

Proposed resolution

Skip empty files in EndFileNewlineSniff::process().

Remaining tasks

Implement.

User interface changes

None except that spurious Drupal.Files.EndFileNewline.NoneFound errors do not appear.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Active

Version

8.3

Component

Coder Sniffer

Created by

🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Liam Morland
  • Status changed to Postponed: needs info 3 months ago
  • 🇦🇹Austria klausi 🇦🇹 Vienna

    Hm, tried to reproduce this on a completely empty file. No error is triggered when running phpcs on it.

    Are you sure your file is empty? "ls -l" must show 0 bytes.

    Maybe you have a \r or other white space in your file?

  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

    There must have been an update to something. It is no longer doing it.

  • 🇦🇹Austria klausi 🇦🇹 Vienna

    Alright, thanks for reporting anyway!

Production build 0.71.5 2024