How the Check Works
The CheckLineEndings
is designed to identify and report inconsistent line endings in your project’s MonoScripts. Inconsistent line endings can lead to compatibility issues across different platforms and code editors.
The check operates at the MonoScript level:
- MonoScript Level: When invoked on a MonoScript, it analyzes the text content of the script, checking for inconsistencies in line endings.
The check performs the following steps:
- Line Endings Analysis: It splits the script’s text into lines and iterates through each line. During this process, it identifies the presence of both carriage return (CR) and line feed (LF) characters.
- Inconsistency Detection: If a line ends with only CR or only LF, the check flags it as inconsistent. If a mixture of CR and LF line endings is detected within the script, it is also considered inconsistent.
- Issue Reporting: If the check identifies inconsistent line endings, it logs an issue with a description indicating the problem and references the MonoScript.
When to Use This Check
- Cross-Platform Compatibility: Ensure that your codebase follows a consistent line ending convention to avoid compatibility issues when working on different platforms or using different code editors.
- Coding Standard Adherence: Maintain adherence to coding standards by identifying and addressing inconsistent line endings within your scripts.
How to Use the Check
Perform Check: Perform the Check via the Verification Window by selecting the MonoScripts you want to check for inconsistent line endings.
Methods
PerformCheck(MonoScript monoScript)
: Initiates the verification process for a specific MonoScript. It analyzes the text content of the script for inconsistent line endings.
Attributes
description
: Provides a short description of what this check does, highlighting its purpose in identifying inconsistent line endings within your project.
longDescription
: Offers a more detailed explanation of the check, providing additional context on how it analyzes and reports inconsistencies in line endings within MonoScripts.