Skip to content
This repository was archived by the owner on Jun 28, 2022. It is now read-only.

Sourcery refactored master branch#1

Open
sourcery-ai[bot] wants to merge 1 commit intomasterfrom
sourcery/master
Open

Sourcery refactored master branch#1
sourcery-ai[bot] wants to merge 1 commit intomasterfrom
sourcery/master

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Apr 14, 2021

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

@sourcery-ai sourcery-ai bot requested a review from guillier April 14, 2021 16:52
Comment on lines -126 to +133
for ds in range(0, ds_cnt):
for ds in range(ds_cnt):
fd.write(fs.read(40))
for i in range(0, 10):
for _ in range(10):
double_read_write_swap_nan()

row_cnt = 0
### __rrd_read(rrd->rra_def, rra_def_t, rrd->stat_head->rra_cnt);
for rra in range(0, rra_cnt):
for _ in range(rra_cnt):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function rrd_convert refactored with the following changes:

if m:
data_source, field, value = m.groups(0)
if not data_source in ds_dict:
if data_source not in ds_dict:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function RRDParser._parse_ds refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

if m:
rra, field, value = m.groups(0)
if not rra in rra_dict:
if rra not in rra_dict:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function RRDParser._parse_rra refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

value[item] = 'U'
else:
value[item] = float(value[item])
value[item] = 'U' if value[item] == 'NaN' else float(value[item])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function RRDParser.parse refactored with the following changes:

Comment on lines -174 to +171
params = {}
params['debug'] = options.debug
params['file'] = options.file

params = {'debug': options.debug, 'file': options.file}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Apr 14, 2021

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 9.73 🙂 9.69 🙂 -0.04 👍
Method Length 74.35 🙂 73.06 🙂 -1.29 👍
Working memory 9.76 🙂 9.57 🙂 -0.19 👍
Quality 57.78% 🙂 58.34% 🙂 0.56% 👍
Other metrics Before After Change
Lines 316 310 -6
Changed files Quality Before Quality After Quality Change
rrd_convert.py 54.46% 🙂 55.25% 🙂 0.79% 👍
rrdinfo-parser.py 61.19% 🙂 61.65% 🙂 0.46% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
rrd_convert.py rrd_convert 21 😞 220 ⛔ 12 😞 34.77% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
rrd_convert.py read_header 12 🙂 190 😞 10 😞 47.68% 😞 Try splitting into smaller methods. Extract out complex expressions
rrdinfo-parser.py RRDParser.parse 9 🙂 201 😞 10 😞 49.55% 😞 Try splitting into smaller methods. Extract out complex expressions
rrdinfo-parser.py RRDParser._parse_ds 11 🙂 89 🙂 12 😞 56.30% 🙂 Extract out complex expressions
rrdinfo-parser.py RRDParser._parse_rra 11 🙂 89 🙂 11 😞 58.03% 🙂 Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

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!

Let us know what you think of it by mentioning @sourcery-ai in a comment.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants

Comments