Method: pylint.checkers.format.FormatChecker._check_line_ending
Calls: 23631, Exceptions: 0, Paths: 4Back
Path 1: 22637 calls (0.96)
'\n' (20741) '\r\n' (1895) '' (1)
9 (489) 8 (488) 7 (458) 6 (453) 10 (449) 5 (440) 11 (424) 12 (377) 13 (367) 15 (356)
1def _check_line_ending(self, line_ending: str, line_num: int) -> None:
2 # check if line endings are mixed
3 if self._last_line_ending is not None:
4 # line_ending == "" indicates a synthetic newline added at
5 # the end of a file that does not, in fact, end with a
6 # newline.
7 if line_ending and line_ending != self._last_line_ending:
8 self.add_message("mixed-line-endings", line=line_num)
9
10 self._last_line_ending = line_ending
11
12 # check if line ending is as expected
13 expected = self.linter.config.expected_line_ending_format
14 if expected:
15 # reduce multiple \n\n\n\n to one \n
16 line_ending = reduce(lambda x, y: x + y if x != y else x, line_ending, "")
17 line_ending = "LF" if line_ending == "\n" else "CRLF"
18 if line_ending != expected:
19 self.add_message(
20 "unexpected-line-ending-format",
21 args=(line_ending, expected),
22 line=line_num,
23 )
Path 2: 992 calls (0.04)
'\n' (939) '\r\n' (50) '' (3)
1 (395) 3 (213) 2 (133) 4 (104) 5 (88) 6 (28) 7 (14) 8 (5) 9 (4) 10 (2)
1def _check_line_ending(self, line_ending: str, line_num: int) -> None:
2 # check if line endings are mixed
3 if self._last_line_ending is not None:
4 # line_ending == "" indicates a synthetic newline added at
5 # the end of a file that does not, in fact, end with a
6 # newline.
7 if line_ending and line_ending != self._last_line_ending:
8 self.add_message("mixed-line-endings", line=line_num)
9
10 self._last_line_ending = line_ending
11
12 # check if line ending is as expected
13 expected = self.linter.config.expected_line_ending_format
14 if expected:
15 # reduce multiple \n\n\n\n to one \n
16 line_ending = reduce(lambda x, y: x + y if x != y else x, line_ending, "")
17 line_ending = "LF" if line_ending == "\n" else "CRLF"
18 if line_ending != expected:
19 self.add_message(
20 "unexpected-line-ending-format",
21 args=(line_ending, expected),
22 line=line_num,
23 )
Path 3: 1 calls (0.0)
'\n' (1)
1 (1)
1def _check_line_ending(self, line_ending: str, line_num: int) -> None:
2 # check if line endings are mixed
3 if self._last_line_ending is not None:
4 # line_ending == "" indicates a synthetic newline added at
5 # the end of a file that does not, in fact, end with a
6 # newline.
7 if line_ending and line_ending != self._last_line_ending:
8 self.add_message("mixed-line-endings", line=line_num)
9
10 self._last_line_ending = line_ending
11
12 # check if line ending is as expected
13 expected = self.linter.config.expected_line_ending_format
14 if expected:
15 # reduce multiple \n\n\n\n to one \n
16 line_ending = reduce(lambda x, y: x + y if x != y else x, line_ending, "")
17 line_ending = "LF" if line_ending == "\n" else "CRLF"
18 if line_ending != expected:
19 self.add_message(
20 "unexpected-line-ending-format",
21 args=(line_ending, expected),
22 line=line_num,
23 )
Path 4: 1 calls (0.0)
'\r\n' (1)
3 (1)
1def _check_line_ending(self, line_ending: str, line_num: int) -> None:
2 # check if line endings are mixed
3 if self._last_line_ending is not None:
4 # line_ending == "" indicates a synthetic newline added at
5 # the end of a file that does not, in fact, end with a
6 # newline.
7 if line_ending and line_ending != self._last_line_ending:
8 self.add_message("mixed-line-endings", line=line_num)
9
10 self._last_line_ending = line_ending
11
12 # check if line ending is as expected
13 expected = self.linter.config.expected_line_ending_format
14 if expected:
15 # reduce multiple \n\n\n\n to one \n
16 line_ending = reduce(lambda x, y: x + y if x != y else x, line_ending, "")
17 line_ending = "LF" if line_ending == "\n" else "CRLF"
18 if line_ending != expected:
19 self.add_message(
20 "unexpected-line-ending-format",
21 args=(line_ending, expected),
22 line=line_num,
23 )