Remi-Gau / nilearn

Machine learning for NeuroImaging in Python
http://nilearn.github.io
Other
1 stars 1 forks source link

TEST: refactor complex functions #17

Closed Remi-Gau closed 1 year ago

github-actions[bot] commented 1 year ago

👋 @Remi-Gau Thanks for creating a PR!

Until this PR is ready for review, you can include the [WIP] tag in its title, or leave it as a github draft.

Please make sure it is compliant with our contributing guidelines. In particular, be sure it checks the boxes listed below.

We will review it as quick as possible, feel free to ping us with questions if needed.

sourcery-ai[bot] commented 1 year ago

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 4.62%.

Quality metrics Before After Change
Complexity 23.12 😞 14.38 🙂 -8.74 👍
Method Length 179.49 😞 159.39 😞 -20.10 👍
Working memory 14.17 😞 13.83 😞 -0.34 👍
Quality 42.68% 😞 47.30% 😞 4.62% 👍
Other metrics Before After Change
Lines 7836 8030 194
Changed files Quality Before Quality After Quality Change
nilearn/connectome/group_sparse_cov.py 25.20% 😞 31.38% 😞 6.18% 👍
nilearn/connectome/tests/test_group_sparse_cov.py 52.96% 🙂 52.96% 🙂 0.00%
nilearn/datasets/func.py 46.71% 😞 51.49% 🙂 4.78% 👍
nilearn/datasets/tests/test_func.py 70.33% 🙂 70.95% 🙂 0.62% 👍
nilearn/glm/first_level/first_level.py 21.61% ⛔ 24.78% ⛔ 3.17% 👍
nilearn/image/resampling.py 28.56% 😞 36.43% 😞 7.87% 👍
nilearn/image/tests/test_resampling.py 61.73% 🙂 61.73% 🙂 0.00%
nilearn/mass_univariate/permuted_least_squares.py 3.57% ⛔ 25.17% 😞 21.60% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
nilearn/glm/first_level/first_level.py first_level_from_bids 84 ⛔ 834 ⛔ 39 ⛔ 0.66% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
nilearn/connectome/group_sparse_cov.py _group_sparse_covariance 64 ⛔ 1018 ⛔ 34 ⛔ 1.87% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
nilearn/image/resampling.py resample_img 42 ⛔ 818 ⛔ 26 ⛔ 6.63% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
nilearn/glm/first_level/first_level.py FirstLevelModel.fit 57 ⛔ 752 ⛔ 18 ⛔ 7.70% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
nilearn/mass_univariate/permuted_least_squares.py permuted_ols 35 ⛔ 855 ⛔ 30 ⛔ 8.16% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

codecov-commenter commented 1 year ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (flake8_cfg@6b25303). Click here to learn what that means. The diff coverage is n/a.

@@              Coverage Diff              @@
##             flake8_cfg      #17   +/-   ##
=============================================
  Coverage              ?   91.09%           
=============================================
  Files                 ?      133           
  Lines                 ?    15387           
  Branches              ?     3028           
=============================================
  Hits                  ?    14017           
  Misses                ?      809           
  Partials              ?      561           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.