mesh-adaptation / goalie

Goal-oriented error estimation and mesh adaptation for finite element problems solved using Firedrake
Other
2 stars 0 forks source link

Fix B and C linting rules #165

Open ddundo opened 5 months ago

ddundo commented 5 months ago

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 commented 3 months ago

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).