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

Fix B and C linting rules #165

Open
ddundo opened this issue Apr 16, 2024 · 1 comment
Open

Fix B and C linting rules #165

ddundo opened this issue Apr 16, 2024 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers testing Extensions and improvements to the testing infrastructure
Milestone

Comments

@ddundo
Copy link
Member

ddundo commented Apr 16, 2024

The current linter does not seem to catch B and C rules even though they are enabled in .flake8.

Running the ruff linter caught the following:

demos/gray_scott.py:173:16: B007 Loop control variable `mesh` not used within loop body
demos/gray_scott_split.py:178:16: B007 Loop control variable `mesh` not used within loop body
demos/solid_body_rotation.py:268:16: B007 Loop control variable `mesh` not used within loop body
demos/solid_body_rotation_split.py:94:16: B007 Loop control variable `mesh` not used within loop body
goalie/adjoint.py:151:45: B006 Do not use mutable data structures for argument defaults
goalie/adjoint.py:224:9: C901 `solve_adjoint` is too complex (37 > 10)
goalie/adjoint.py:226:23: B006 Do not use mutable data structures for argument defaults
goalie/adjoint.py:227:27: B006 Do not use mutable data structures for argument defaults
goalie/error_estimation.py:63:5: C901 `get_dwr_indicator` is too complex (14 > 10)
goalie/function_data.py:19:7: B024 `FunctionData` is an abstract base class, but it has no abstract methods
goalie/go_mesh_seq.py:126:33: B006 Do not use mutable data structures for argument defaults
goalie/go_mesh_seq.py:126:51: B006 Do not use mutable data structures for argument defaults
goalie/go_mesh_seq.py:165:16: B007 Loop control variable `mesh` not used within loop body
goalie/go_mesh_seq.py:279:9: C901 `fixed_point_iteration` is too complex (11 > 10)
goalie/go_mesh_seq.py:283:27: B006 Do not use mutable data structures for argument defaults
goalie/go_mesh_seq.py:284:24: B006 Do not use mutable data structures for argument defaults
goalie/go_mesh_seq.py:285:23: B006 Do not use mutable data structures for argument defaults
goalie/go_mesh_seq.py:324:13: B020 Loop control variable `self` overrides iterable it iterates
goalie/mesh_seq.py:53:28: C416 Unnecessary `dict` comprehension (rewrite using `dict()`)
goalie/mesh_seq.py:451:45: B006 Do not use mutable data structures for argument defaults
goalie/mesh_seq.py:695:9: C901 `solve_forward` is too complex (12 > 10)
goalie/mesh_seq.py:695:43: B006 Do not use mutable data structures for argument defaults
goalie/mesh_seq.py:828:58: B006 Do not use mutable data structures for argument defaults
goalie/mesh_seq.py:828:77: B006 Do not use mutable data structures for argument defaults
goalie/mesh_seq.py:855:13: B020 Loop control variable `self` overrides iterable it iterates
goalie/metric.py:64:5: C901 `space_time_normalise` is too complex (16 > 10)
goalie/options.py:19:35: B006 Do not use mutable data structures for argument defaults
goalie/options.py:35:18: B007 Loop control variable `value` not used within loop body
goalie/options.py:81:20: C416 Unnecessary `dict` comprehension (rewrite using `dict()`)
goalie/options.py:94:35: B006 Do not use mutable data structures for argument defaults
goalie/options.py:182:35: B006 Do not use mutable data structures for argument defaults
goalie/time_partition.py:143:13: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
goalie/utility.py:154:5: C901 `norm` is too complex (13 > 10)
goalie/utility.py:210:17: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
goalie/utility.py:226:5: C901 `errornorm` is too complex (12 > 10)
test/test_function_data.py:208:13: B007 Loop control variable `i` not used within loop body
test/test_utility.py:301:9: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
test_adjoint/test_adjoint.py:77:5: C901 `test_adjoint_same_mesh` is too complex (16 > 10)
Found 38 errors.
ddundo added a commit that referenced this issue Apr 16, 2024
@jwallwork23 jwallwork23 added bug Something isn't working testing Extensions and improvements to the testing infrastructure labels Apr 17, 2024
@jwallwork23 jwallwork23 added this to the Version 1 milestone Apr 17, 2024
ddundo added a commit that referenced this issue Apr 17, 2024
Closes #162.

This PR introduces ruff for linting and formatting. I temporarily disabled "B" and "C" linting rules as they were blocking
the push. See #165.
@ddundo ddundo self-assigned this May 9, 2024
@ddundo ddundo moved this from Backlog to In Progress in Mesh Adaptation development board May 9, 2024
ddundo added a commit that referenced this issue May 9, 2024
ddundo added a commit that referenced this issue May 9, 2024
ddundo added a commit that referenced this issue May 10, 2024
Partially addresses #165.
ddundo added a commit that referenced this issue Jun 23, 2024
ddundo added a commit that referenced this issue Jun 24, 2024
Sorry, I missed two things when addressing #165 and #195 which this PR addresses.
@ddundo
Copy link
Member Author

ddundo commented Jun 25, 2024

Edit: After #204, only C901 errors remain:

goalie/adjoint.py:187:9: C901 `get_solve_blocks` is too complex (13 > 10)
goalie/adjoint.py:384:9: C901 `solve_adjoint` is too complex (38 > 10)
goalie/error_estimation.py:63:5: C901 `get_dwr_indicator` is too complex (14 > 10)
goalie/go_mesh_seq.py:286:9: C901 `fixed_point_iteration` is too complex (11 > 10)
goalie/mesh_seq.py:494:9: C901 `_solve_forward` is too complex (12 > 10)
goalie/metric.py:64:5: C901 `space_time_normalise` is too complex (16 > 10)
test_adjoint/test_adjoint.py:78:5: C901 `test_adjoint_same_mesh` is too complex (18 > 10)

These will be addressed at a later point, after the restructuring of goalie (#189).

ddundo added a commit that referenced this issue Jun 25, 2024
ddundo added a commit that referenced this issue Jun 25, 2024
@ddundo ddundo added the good first issue Good for newcomers label Jun 25, 2024
ddundo added a commit that referenced this issue Jun 26, 2024
Partially addresses #165.

I enabled C linting rules but added C901 ("function is too complex") to
the ignore list.
@ddundo ddundo moved this from In Progress to Blocked in Mesh Adaptation development board Jun 26, 2024
@ddundo ddundo removed their assignment Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers testing Extensions and improvements to the testing infrastructure
Projects
Development

No branches or pull requests

2 participants