forked from astronomer/astronomer-cosmos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce Mccabe code complexity to 8 (astronomer#738)
Reduce the maccabe score from 10 to 8 and refactored the code flagged as too complex. I removed flake8, since we can use ruffs maccabe linter. The following functions have been addressed ```shell > pre-commit run flake8 --all-files flake8...................................................................Failed - hook id: flake8 - exit code: 1 cosmos/airflow/graph.py:196:1: C901 'build_airflow_graph' is too complex (9) cosmos/converter.py:101:5: C901 'DbtToAirflowConverter.__init__' is too complex (9) cosmos/dbt/parser/project.py:277:5: C901 'LegacyDbtProject.__post_init__' is too complex (10) cosmos/dbt/selector.py:197:1: C901 'select_nodes' is too complex (9) ``` I picked out the functions which stood out to me as complex. If we want to reduce it to 6, there are plenty more functions to tackle. For some functions I would consider it unnecessary to drop it to 6. ```shell cosmos/config.py:108:9: C901 `__init__` is too complex (7 > 6) cosmos/dbt/parser/project.py:63:9: C901 `_config_selector_ooo` is too complex (7 > 6) cosmos/dbt/parser/project.py:98:5: C901 `extract_python_file_upstream_requirements` is too complex (7 > 6) cosmos/dbt/parser/project.py:165:9: C901 `extract_sql_file_requirements` is too complex (7 > 6) cosmos/dbt/selector.py:52:9: C901 `load_from_statement` is too complex (7 > 6) cosmos/dbt/selector.py:119:9: C901 `_should_include_node` is too complex (7 > 6) cosmos/hooks/subprocess.py:34:9: C901 `run_command` is too complex (8 > 6) cosmos/operators/base.py:137:9: C901 `get_env` is too complex (7 > 6) cosmos/operators/base.py:186:9: C901 `add_global_flags` is too complex (7 > 6) cosmos/operators/local.py:136:9: C901 `store_compiled_sql` is too complex (7 > 6) cosmos/profiles/base.py:183:9: C901 `get_dbt_value` is too complex (8 > 6) Found 11 errors. ``` This PR continues on the amazing work of @jbandoro on astronomer#525 Related issue astronomer#641
- Loading branch information
Showing
5 changed files
with
102 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -260,5 +260,5 @@ line-length = 120 | |
universal = true | ||
|
||
[tool.flake8] | ||
max-complexity = 10 | ||
max-complexity = 8 | ||
select = "C" |