Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed multiple SwiftLint violations #772

Merged

Conversation

mildm8nnered
Copy link
Contributor

I ran SwiftLint against Periphery (and vice versa), and there were many rules with a small number of violations and trivial fixes.

A lot of changes were just whitespace (trailing spaces, more than one new line at the end of a file) - some small code changes to equivalent constructs.

Of the remaining violations, quite a few are in test fixtures and intentional. I didn't want to start sprinkling // swiftlint:disable:next statements, but that would be the obvious thing to do with these.

Before:

% swiftlint --progress --reporter summary          
Linting Swift files in current working directory
368 of 368 [==============================] ETA: 0s (780 files/s)
+-----------------------------------------+--------+-------------+--------+----------+--------+------------------+-----------------+
| rule identifier                         | opt-in | correctable | custom | warnings | errors | total violations | number of files |
+-----------------------------------------+--------+-------------+--------+----------+--------+------------------+-----------------+
| line_length                             | no     | no          | no     |      184 |     11 |              195 |              67 |
| type_name                               | no     | no          | no     |       51 |     37 |               88 |              38 |
| identifier_name                         | no     | no          | no     |       13 |     71 |               84 |              38 |
| trailing_comma                          | no     | yes         | no     |       22 |      0 |               22 |               7 |
| empty_parentheses_with_trailing_closure | no     | yes         | no     |       16 |      0 |               16 |               2 |
| trailing_whitespace                     | no     | yes         | no     |       13 |      0 |               13 |               8 |
| force_try                               | no     | no          | no     |        0 |     12 |               12 |               5 |
| cyclomatic_complexity                   | no     | no          | no     |        8 |      3 |               11 |               8 |
| for_where                               | no     | no          | no     |       11 |      0 |               11 |               8 |
| function_body_length                    | no     | no          | no     |        6 |      1 |                7 |               4 |
| nesting                                 | no     | no          | no     |        7 |      0 |                7 |               3 |
| opening_brace                           | no     | yes         | no     |        6 |      0 |                6 |               5 |
| type_body_length                        | no     | no          | no     |        1 |      5 |                6 |               5 |
| redundant_discardable_let               | no     | yes         | no     |        5 |      0 |                5 |               4 |
| trailing_newline                        | no     | yes         | no     |        5 |      0 |                5 |               5 |
| file_length                             | no     | no          | no     |        3 |      1 |                4 |               4 |
| non_optional_string_data_conversion     | no     | no          | no     |        4 |      0 |                4 |               4 |
| unneeded_synthesized_initializer        | no     | yes         | no     |        4 |      0 |                4 |               4 |
| unused_closure_parameter                | no     | yes         | no     |        4 |      0 |                4 |               2 |
| colon                                   | no     | yes         | no     |        3 |      0 |                3 |               3 |
| function_parameter_count                | no     | no          | no     |        3 |      0 |                3 |               3 |
| is_disjoint                             | no     | no          | no     |        3 |      0 |                3 |               1 |
| large_tuple                             | no     | no          | no     |        2 |      1 |                3 |               3 |
| unneeded_override                       | no     | yes         | no     |        3 |      0 |                3 |               2 |
| force_cast                              | no     | no          | no     |        0 |      2 |                2 |               1 |
| inclusive_language                      | no     | no          | no     |        2 |      0 |                2 |               1 |
| redundant_optional_initialization       | no     | yes         | no     |        2 |      0 |                2 |               1 |
| syntactic_sugar                         | no     | yes         | no     |        2 |      0 |                2 |               1 |
| todo                                    | no     | no          | no     |        2 |      0 |                2 |               2 |
| unused_optional_binding                 | no     | no          | no     |        2 |      0 |                2 |               2 |
| void_return                             | no     | yes         | no     |        2 |      0 |                2 |               1 |
| control_statement                       | no     | yes         | no     |        1 |      0 |                1 |               1 |
| empty_enum_arguments                    | no     | yes         | no     |        1 |      0 |                1 |               1 |
| operator_whitespace                     | no     | no          | no     |        1 |      0 |                1 |               1 |
| return_arrow_whitespace                 | no     | yes         | no     |        1 |      0 |                1 |               1 |
| unused_setter_value                     | no     | no          | no     |        1 |      0 |                1 |               1 |
+-----------------------------------------+--------+-------------+--------+----------+--------+------------------+-----------------+
| Total                                   |        |             |        |      394 |    144 |              538 |             160 |
+-----------------------------------------+--------+-------------+--------+----------+--------+------------------+-----------------+
Done linting! Found 538 violations, 144 serious in 368 files.

After:

 % swiftlint --progress --reporter summary
Linting Swift files in current working directory
368 of 368 [==============================] ETA: 0s (4967 files/s)
+-----------------------------------------+--------+-------------+--------+----------+--------+------------------+-----------------+
| rule identifier                         | opt-in | correctable | custom | warnings | errors | total violations | number of files |
+-----------------------------------------+--------+-------------+--------+----------+--------+------------------+-----------------+
| line_length                             | no     | no          | no     |      187 |     11 |              198 |              69 |
| type_name                               | no     | no          | no     |       51 |     37 |               88 |              38 |
| identifier_name                         | no     | no          | no     |       13 |     71 |               84 |              38 |
| empty_parentheses_with_trailing_closure | no     | yes         | no     |       16 |      0 |               16 |               2 |
| force_try                               | no     | no          | no     |        0 |     12 |               12 |               5 |
| cyclomatic_complexity                   | no     | no          | no     |        8 |      3 |               11 |               8 |
| function_body_length                    | no     | no          | no     |        6 |      1 |                7 |               4 |
| nesting                                 | no     | no          | no     |        7 |      0 |                7 |               3 |
| type_body_length                        | no     | no          | no     |        1 |      5 |                6 |               5 |
| opening_brace                           | no     | yes         | no     |        5 |      0 |                5 |               4 |
| redundant_discardable_let               | no     | yes         | no     |        5 |      0 |                5 |               4 |
| file_length                             | no     | no          | no     |        3 |      1 |                4 |               4 |
| non_optional_string_data_conversion     | no     | no          | no     |        4 |      0 |                4 |               4 |
| unneeded_synthesized_initializer        | no     | yes         | no     |        4 |      0 |                4 |               4 |
| unused_closure_parameter                | no     | yes         | no     |        4 |      0 |                4 |               2 |
| function_parameter_count                | no     | no          | no     |        3 |      0 |                3 |               3 |
| large_tuple                             | no     | no          | no     |        2 |      1 |                3 |               3 |
| unneeded_override                       | no     | yes         | no     |        3 |      0 |                3 |               2 |
| force_cast                              | no     | no          | no     |        0 |      2 |                2 |               1 |
| todo                                    | no     | no          | no     |        2 |      0 |                2 |               2 |
| control_statement                       | no     | yes         | no     |        1 |      0 |                1 |               1 |
| unused_optional_binding                 | no     | no          | no     |        1 |      0 |                1 |               1 |
| unused_setter_value                     | no     | no          | no     |        1 |      0 |                1 |               1 |
+-----------------------------------------+--------+-------------+--------+----------+--------+------------------+-----------------+
| Total                                   |        |             |        |      327 |    144 |              471 |             144 |
+-----------------------------------------+--------+-------------+--------+----------+--------+------------------+-----------------+
Done linting! Found 471 violations, 144 serious in 368 files.

@ileitch ileitch merged commit 9fa573e into peripheryapp:master Aug 3, 2024
4 checks passed
@ileitch
Copy link
Contributor

ileitch commented Aug 3, 2024

Thanks! I really need to integrate SwiftLint and SwiftFormat 😅.

@mildm8nnered mildm8nnered deleted the mildm8nnered-fix-swiftlint-issues branch August 4, 2024 01:43
@mildm8nnered
Copy link
Contributor Author

Thanks! I really need to integrate SwiftLint and SwiftFormat 😅.

So I would be happy to help with that if you let me know what approach you'd like to take

rofle100lvl pushed a commit to rofle100lvl/periphery that referenced this pull request Aug 4, 2024
@ileitch
Copy link
Contributor

ileitch commented Aug 4, 2024

So I would be happy to help with that if you let me know what approach you'd like to take

Awesome 😄. I think just a make command to run them both plus a blocking CI pass should be enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants