Skip to content

SCR124: trailing-whitespace

Spaces or tabs at the end of a script line

Code SCR124
Name trailing-whitespace
Category Scripts (SCR)
Default severity info
Enabled by default no
Fix available always
Fix safety safe or unsafe, depending on the finding (see below)
ign-lint equivalent none

Reports spaces, tabs and form feeds at the end of script lines, also on lines that hold nothing else, in library modules, event files and every script embedded in a view or another resource.

Whitespace inside a multi-line string literal is part of the string's value and is not reported, and so is whitespace after a backslash in a single-quoted string that a line break ends: Jython drops such a string with the line break and lexes on, and without the whitespace the backslash would continue the string on the next line. Scripts that do not parse are not checked (SCR001 reports them).

Trailing whitespace is invisible in the Designer's script editor, makes diffs noisy and often differs between developers' editors, so the same script keeps changing in version control.

def runAction(self, event):
value = event.value
self.props.text = value

Use instead:

def runAction(self, event):
value = event.value
self.props.text = value

Removes the whitespace. Safe: the whitespace is in no value and no line moves. The fix only changes layout, so it is safe only when every token of the script stays as it is (checked by lexing the script before and after); whitespace that Jython's lexer reads, such as the whitespace after a backslash that is not followed by a line break, makes it unsafe. Like every fix, it is unsafe while code in the workspace may read the files a fix edits (any file access, read, write, rename or delete, whose path is not a literal outside the workspace, or code that is not vetted); the project setting [fix] assume-scripts-do-not-read-workspace-files = true declares that no script does (see docs/internal/fix-safety.md, "File reads").

Corresponds to C0303 trailing-whitespace.


Generated from the rule metadata by iglint generate-docs; iglint rule SCR124 prints the same page in the terminal. Source: docs/rules/SCR124.md.