NAME
Perl::Critic::Policy::CodeLayout::LimitLineLength - Limit the length of lines
VERSION
version v0.1.0
SYNOPSIS
[CodeLayout::LimitLineLength]
max_line_length = 72
# Bad - line exceeds configured maximum
my $very_long_variable_name = "long string that exceeds maximum length";
# Good - line within limit
my $very_long_variable_name =
"long string that exceeds maximum length";
DESCRIPTION
This policy flags lines that exceed a configurable maximum length. Long lines can be difficult to read, especially in narrow terminal windows or when viewing code side-by-side with diffs or other files.
The default maximum line length is 80 characters, which provides good readability across various display contexts while still allowing reasonable code density.
You can configure perltidy
to keep lines within the specified limit. Only when it is unable to do that will you need to manually make changes.
CONFIGURATION
max_line_length
The maximum allowed line length in characters. Defaults to 80.
[CodeLayout::LimitLineLength]
max_line_length = 72
EXAMPLES
Long Variable Assignments
# Bad - exceeds 72 characters
my $configuration_manager = VeryLongModuleName::ConfigurationManager->new;
# Good - broken into multiple lines
my $configuration_manager =
VeryLongModuleName::ConfigurationManager->new;
Long Method Calls
# Bad - exceeds 72 characters
$object->some_very_very_long_method_name($param1, $param2, $param3, $param4);
# Good - parameters on separate lines
$object->some_very_very_long_method_name(
$param1, $param2, $param3, $param4
);
Long String Literals
# Bad - exceeds 72 characters
my $error_message =
"This is a very long error message that exceeds the configured maximum";
# Good - use concatenation or heredoc
my $error_message = "This is a very long error message that " .
"exceeds the configured maximum";
METHODS
supported_parameters
This method returns the parameters supported by this policy.
AFFILIATION
This Policy is part of the Perl::Critic::PJCJ distribution.
AUTHOR
Paul Johnson <paul@pjcj.net>
COPYRIGHT
Copyright 2025 Paul Johnson.
LICENCE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.