Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery refactored main branch #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Sourcery refactored main branch #28

wants to merge 1 commit into from

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Sep 27, 2022

Branch main 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 main branch, then run:

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

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from garlontas September 27, 2022 13:18
Comment on lines -30 to +33
builder.add_from_file("{}/data/ffripper.glade".format(os.path.dirname(os.path.realpath(__file__))))
builder.add_from_file(
f"{os.path.dirname(os.path.realpath(__file__))}/data/ffripper.glade"
)

Copy link
Author

Choose a reason for hiding this comment

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

Lines 30-30 refactored with the following changes:

@@ -24,18 +24,20 @@
A fast, powerful and simple-to-use graphical CD ripper
"""

Copy link
Author

Choose a reason for hiding this comment

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

Lines 34-38 refactored with the following changes:

Comment on lines -71 to +121
for j in range(len(self.dict['disc']['release-list'][0]['medium-list'][i]['track-list'])):
tracks.append(
TrackInfo(self.dict['disc']['release-list'][0]['medium-list'][i]['track-list'][j]
['recording']["title"],
self.dict['disc']['release-list'][0]['medium-list'][i]['track-list'][j][
'length'],
self.dict['disc']['release-list'][0]['date'],
self.dict['disc']['release-list'][0]['medium-list'][i]['track-list']
[j]['recording']['artist-credit'][0]['artist']['name']))
tracks.extend(
TrackInfo(
self.dict['disc']['release-list'][0][
'medium-list'
][i]['track-list'][j]['recording']["title"],
self.dict['disc']['release-list'][0][
'medium-list'
][i]['track-list'][j]['length'],
self.dict['disc']['release-list'][0]['date'],
self.dict['disc']['release-list'][0][
'medium-list'
][i]['track-list'][j]['recording'][
'artist-credit'
][
0
][
'artist'
][
'name'
],
)
for j in range(
len(
self.dict['disc']['release-list'][0][
'medium-list'
][i]['track-list']
)
)
)

except IndexError:
for i in range(len(self.dict['disc']['release-list'][0]['medium-list'][0]['track-list'])):
tracks.append(
TrackInfo(self.dict['disc']['release-list'][0]['medium-list'][0]['track-list'][i]['recording'][
"title"],
self.dict['disc']['release-list'][0]['medium-list'][0]['track-list'][i]['length'],
self.dict['disc']['release-list'][0]['date'], None))
tracks.extend(
TrackInfo(
self.dict['disc']['release-list'][0]['medium-list'][0][
'track-list'
][i]['recording']["title"],
self.dict['disc']['release-list'][0]['medium-list'][0][
'track-list'
][i]['length'],
self.dict['disc']['release-list'][0]['date'],
None,
)
for i in range(
len(
self.dict['disc']['release-list'][0]['medium-list'][0][
'track-list'
]
)
)
)

Copy link
Author

Choose a reason for hiding this comment

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

Function CdDiscParser.parse_for_tracks refactored with the following changes:

def bytes2png(data, output_dir, filename): # type: (bytes, str, str) -> str
def bytes2png(data, output_dir, filename): # type: (bytes, str, str) -> str
Copy link
Author

Choose a reason for hiding this comment

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

Function Image.bytes2png refactored with the following changes:

self._player.set_property("uri", "file://" + self.filepath)
self._player.set_property("uri", f"file://{self.filepath}")
Copy link
Author

Choose a reason for hiding this comment

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

Function Player.set_file refactored with the following changes:

Comment on lines -83 to +84
logger.debug("Current fraction: {}%".format(window.progressbar.get_fraction() * 100))
logger.debug("Fraction: {}".format(percentage))
logger.debug(f"Current fraction: {window.progressbar.get_fraction() * 100}%")
logger.debug(f"Fraction: {percentage}")
Copy link
Author

Choose a reason for hiding this comment

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

Function MyCopyListener.__main_thread_updater refactored with the following changes:

self.player.set_file(self.disc.mount_point + "/" + self.disc_tracks[0])
self.player.set_file(f"{self.disc.mount_point}/{self.disc_tracks[0]}")
Copy link
Author

Choose a reason for hiding this comment

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

Function RipperWindow.set_player refactored with the following changes:

Comment on lines -387 to +390
logger.debug("Changed row: {}".format(row))
logger.debug(f"Changed row: {row}")
self.player.reset()
index = int(row.get_indices()[0])
self.player.set_file(self.disc.mount_point + "/" + self.disc_tracks[index])
self.player.set_file(f"{self.disc.mount_point}/{self.disc_tracks[index]}")
Copy link
Author

Choose a reason for hiding this comment

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

Function RipperWindow.on_tree_view_columns_changed refactored with the following changes:

Comment on lines -469 to +472
window = RipperWindow(builder, data + "settings.yaml")
window = RipperWindow(builder, f"{data}settings.yaml")
load = Loader()
load.load_formats(formats)
load.load_settings(data + "settings.yaml")
load.load_settings(f"{data}settings.yaml")
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:

Comment on lines -65 to +66
folder = None
response = dialog.run()
if response == Gtk.ResponseType.OK:
folder = dialog.get_filename()
folder = dialog.get_filename() if response == Gtk.ResponseType.OK else None
Copy link
Author

Choose a reason for hiding this comment

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

Function UiObjects.chooser refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Sep 27, 2022

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 3.19 ⭐ 2.93 ⭐ -0.26 👍
Method Length 49.81 ⭐ 49.76 ⭐ -0.05 👍
Working memory 5.91 ⭐ 6.01 ⭐ 0.10 👎
Quality 79.49% 79.62% 0.13% 👍
Other metrics Before After Change
Lines 872 904 32
Changed files Quality Before Quality After Quality Change
FFRipper 86.39% ⭐ 86.55% ⭐ 0.16% 👍
ffripper/init.py 89.53% ⭐ 85.70% ⭐ -3.83% 👎
ffripper/disc_parser.py 63.69% 🙂 67.62% 🙂 3.93% 👍
ffripper/image.py 84.40% ⭐ 84.27% ⭐ -0.13% 👎
ffripper/player.py 83.55% ⭐ 83.52% ⭐ -0.03% 👎
ffripper/process_launcher.py 77.02% ⭐ 77.05% ⭐ 0.03% 👍
ffripper/progress.py 52.91% 🙂 52.23% 🙂 -0.68% 👎
ffripper/ui.py 82.23% ⭐ 82.14% ⭐ -0.09% 👎
ffripper/ui_elements.py 89.75% ⭐ 89.81% ⭐ 0.06% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
ffripper/disc_parser.py CdDiscParser.parse_for_tracks 11 🙂 317 ⛔ 18 ⛔ 31.22% 😞 Try splitting into smaller methods. Extract out complex expressions
ffripper/progress.py FFmpegProgress.parse_output 20 😞 145 😞 15 😞 37.68% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
ffripper/ui.py RipperWindow.on_copy_button_clicked 13 🙂 155 😞 10 😞 50.02% 🙂 Try splitting into smaller methods. Extract out complex expressions
ffripper/process_launcher.py CopyProcessor.run 7 ⭐ 204 😞 8 🙂 55.48% 🙂 Try splitting into smaller methods
ffripper/ui.py RipperWindow.set_treeview_content 10 🙂 144 😞 6 ⭐ 62.94% 🙂 Try splitting into smaller methods

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!

Help us improve this quality report!

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 16 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants