Skip to content

SA1518 should not trigger on empty files #3926

@DWIAltonaAnalytics

Description

@DWIAltonaAnalytics

The "file has to end with newline" should not be triggered if a file does not contain anything.

if the file size is 0 bytes, that file does not contain lines of text (as for example defined by posix: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206) and thus does not have to end in a newline.

the problem occurs for example in protoc-generated c#-code - for some reason the protobuf compiler creates some empty (0bytes) files and these then trigger the error.

Obviously, if these files would contain a line marking the file as autogenerated the check would be all right, because the file would not be empty anymore.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions