Closed cosimoNigro closed 2 years ago
✅ Merging this PR will increase code quality in the affected files by 0.18%.
Quality metrics | Before | After | Change |
---|---|---|---|
Complexity | 2.19 ⭐ | 2.03 ⭐ | -0.16 👍 |
Method Length | 49.68 ⭐ | 49.63 ⭐ | -0.05 👍 |
Working memory | 12.00 😞 | 11.98 😞 | -0.02 👍 |
Quality | 70.54% 🙂 | 70.72% 🙂 | 0.18% 👍 |
Other metrics | Before | After | Change |
---|---|---|---|
Lines | 310 | 311 | 1 |
Changed files | Quality Before | Quality After | Quality Change |
---|---|---|---|
agnpy/emission_regions/blob.py | 70.54% 🙂 | 70.72% 🙂 | 0.18% 👍 |
Here are some functions in these files that still need a tune-up:
File | Function | Complexity | Length | Working Memory | Quality | Recommendation |
---|---|---|---|---|---|---|
agnpy/emission_regions/blob.py | Blob.__init__ | 0 ⭐ | 180 😞 | 26 ⛔ | 45.27% 😞 | Try splitting into smaller methods. Extract out complex expressions |
agnpy/emission_regions/blob.py | init_spectrum_norm_dict | 11 🙂 | 135 😞 | 14 😞 | 47.35% 😞 | Try splitting into smaller methods. Extract out complex expressions |
agnpy/emission_regions/blob.py | Blob.__str__ | 0 ⭐ | 105 🙂 | 26 ⛔ | 53.57% 🙂 | Extract out complex expressions |
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!
Merging #106 (c67a592) into master (0113497) will not change coverage. The diff coverage is
100.00%
.
@@ Coverage Diff @@
## master #106 +/- ##
=======================================
Coverage 96.33% 96.33%
=======================================
Files 30 30
Lines 2208 2208
=======================================
Hits 2127 2127
Misses 81 81
Flag | Coverage Δ | |
---|---|---|
unittests | 96.33% <100.00%> (ø) |
Flags with carried forward coverage won't be shown. Click here to find out more.
Impacted Files | Coverage Δ | |
---|---|---|
agnpy/emission_regions/blob.py | 88.28% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 0113497...c67a592. Read the comment docs.
@pawel can you continue on this branch with linting the rest of the code?
Yes, I will continue working on this branch.
Sorry, maybe a trivial question but I lost.
How can I push my change to this branch?
I tried git push upstream pylint_and_flake8
where upstream https://github.com/cosimoNigro/agnpy.git
and I got the following error:
remote: Permission to cosimoNigro/agnpy.git denied to pawel21.
fatal: unable to access 'https://github.com/cosimoNigro/agnpy.git/': The requested URL returned error: 403
before I got branch by git checkout -b pylint_and_flake8 upstream/pylint_and_flake8
Hey @pawel21,
two things come to my mind:
1) if you are working on your fork did you try to update the fork? i.e. did you try to pull the branch pylint_and_flake8
from the upstream
?
I think this should have been achieved by your git checkout -b pylint_and_flake8 upstream/pylint_and_flake8
but I am not sure, I always synch my origin
with the upstream
before checking out the branch.
2) try to use ssh instead of https. Since they updated git to work with double authentication I have an ssh key and I use a ssh connection instead of the http.
Let me know if you manage and if I can help you. Cosimo
Dear @pawel21,
thanks for helping me with linting and flaking our code. From a bit of reading it seems that there is some overlap between the checks that
pylint
andflake8
perform.From a superficial reading, it seems to me that
pylint
is the more complete, so I would suggest use it as reference.As you rightly pointed out though, there are a lot of error and warning messages printed, but you can avoid some of them by specifying some settings. For example, by default, variable, attributes and method should all follow the
snake_case
notation, so there should be no upper case letters. In our case this is a bit difficult as we try to "mimic" the math notation (e.g. the magnetic field is always upper case) or, for example, there is a clear difference between a lower and upper case Lorentz factor gamma. I disabled some of this warning through a.pylintrc
file that you can find in this PR.pylint
will automatically detect and use it. After that, most of the warnings left were due to trailing whitespaces in the comments - I suggest you use some feature of your text editor to spot and remove them.To start the global linting I used
pylint
on theemission_regions/blob.py
module. After some corrections this is the output ofpylint
that I get by runningmuch more reduced with respect to initial list of warnings we were getting. I think it's a good score, the warning left are due to too long comment lines (that cannot be split because they contain math expressions or will break the itemising in sphinx. Then there are some warnings on the number of arguments and attributes of a class and where they should be initialised, but I think the last word on these should be on the developers. So I will not disable these warnings.
As a bonus we get also a decent score with
flake8
. Only warning about the length of the comments are left@pawel can you continue on this branch with linting the rest of the code? I think a score around 8 is acceptable.