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 master branch #1

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

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Aug 12, 2022

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^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from WaDn-X August 12, 2022 14:51
Comment on lines -17 to +22

self.data = ''

self.length = None
self.set_terminator(2)

Copy link
Author

Choose a reason for hiding this comment

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

Found the following improvement in Function AionConnection.__init__:


Copy link
Author

Choose a reason for hiding this comment

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

Function AionConnection.decrypt_message refactored with the following changes:

Comment on lines -55 to +52

if not self.encryption_key:
return data

Copy link
Author

Choose a reason for hiding this comment

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

Function AionConnection.encrypt_message refactored with the following changes:

Comment on lines -168 to +160

self.server = None
self.modules = []

Copy link
Author

Choose a reason for hiding this comment

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

Found the following improvement in Function AionClientConnection.__init__:

Comment on lines -178 to +173
__import__('modules.'+name)
module = sys.modules['modules.'+name]
__import__(f'modules.{name}')

module = sys.modules[f'modules.{name}']

if self.modules.count(module) > 0:
reload(self.modules[self.modules.index(module)])

Copy link
Author

Choose a reason for hiding this comment

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

Function AionClientConnection.load_module refactored with the following changes:

Comment on lines -460 to +469

quests = []

for i in range(0, quests_length):
quests.append(struct.unpack('I', data[4+(4*i):8+(4*i)])[0])

print 'server_questlist', quests


quests = [
struct.unpack('I', data[4 + (4 * i) : 8 + (4 * i)])[0]
for i in range(quests_length)
]


(quests_length,) = struct.unpack('I', data[:4])

Copy link
Author

Choose a reason for hiding this comment

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

Function preprocess_server_questlist refactored with the following changes:

Comment on lines -4 to +6
quests = {}
tree = lxml.objectify.parse(open('quest.xml'))

for quest in tree.getroot().quest:
quests[quest.id.pyval] = quest
quests = {quest.id.pyval: quest for quest in tree.getroot().quest}
Copy link
Author

Choose a reason for hiding this comment

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

Lines 4-8 refactored with the following changes:

Comment on lines -25 to +34

if tokens[0] == 'nudge':

if len(tokens) < 4:
return None

x = float(tokens[1])
y = float(tokens[2])
z = float(tokens[3])

Copy link
Author

Choose a reason for hiding this comment

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

Found the following improvement in Function preprocess_client_whisper:

Comment on lines -37 to +60

(player_id, objid, unknown, status) = struct.unpack('=2IHB', data)

if player_id != 0x30562:
return
if status == 0 or status == 1:

if status in [0, 1]:
return

if status == 2:
success += 1

if status == 4:
failure += 1

if success+failure >= 4:

if success < 3:
constructors.client_abandon_quest(server.client, work_order_id)
else:
constructors.client_npcoption(server.client, expert_id, 17, 1, 5, work_order_id, 0)

return

Copy link
Author

Choose a reason for hiding this comment

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

Function postprocess_server_craft_status refactored with the following changes:

Comment on lines -73 to +79

(quests_length,) = struct.unpack('I', data[:4])

quests = []

for i in range(0, quests_length):
quests.append(struct.unpack('I', data[4+(4*i):8+(4*i)])[0])

if work_order_id in quests:
#constructors.client_npcoption(server.client, expert_id, 1002, 1, 4, work_order_id, 0)
pass

quests = [
struct.unpack('I', data[4 + (4 * i) : 8 + (4 * i)])[0]
for i in range(quests_length)
]
Copy link
Author

Choose a reason for hiding this comment

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

Function postprocess_server_available_quest_list refactored with the following changes:

This removes the following comments ( why? ):

#constructors.client_npcoption(server.client, expert_id, 1002, 1, 4, work_order_id, 0)

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Aug 12, 2022

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 1.93 ⭐ 1.82 ⭐ -0.11 👍
Method Length 42.77 ⭐ 42.76 ⭐ -0.01 👍
Working memory 8.61 🙂 8.66 🙂 0.05 👎
Quality 78.35% 78.45% 0.10% 👍
Other metrics Before After Change
Lines 1417 1410 -7
Changed files Quality Before Quality After Quality Change
pyon.py 83.43% ⭐ 84.27% ⭐ 0.84% 👍
modules/barrage.py 58.24% 🙂 58.11% 🙂 -0.13% 👎
modules/constructors.py 83.62% ⭐ 83.62% ⭐ 0.00%
modules/gatherer.py 76.94% ⭐ 77.24% ⭐ 0.30% 👍
modules/handlers.py 79.30% ⭐ 79.20% ⭐ -0.10% 👎
modules/quests.py 93.24% ⭐ 94.74% ⭐ 1.50% 👍
modules/warpzone.py 66.46% 🙂 66.46% 🙂 0.00%
modules/workhorse.py 71.28% 🙂 71.21% 🙂 -0.07% 👎

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

File Function Complexity Length Working Memory Quality Recommendation
modules/barrage.py preprocess_client_skill 11 🙂 216 ⛔ 15 😞 38.78% 😞 Try splitting into smaller methods. Extract out complex expressions
modules/handlers.py preprocess_client_create_character 0 ⭐ 195 😞 62 ⛔ 42.40% 😞 Try splitting into smaller methods. Extract out complex expressions
modules/handlers.py preprocess_server_system_message 5 ⭐ 142 😞 15 😞 50.95% 🙂 Try splitting into smaller methods. Extract out complex expressions
modules/workhorse.py postprocess_server_craft_status 8 ⭐ 104 🙂 16 ⛔ 51.61% 🙂 Extract out complex expressions
modules/handlers.py preprocess_client_location 8 ⭐ 131 😞 13 😞 52.00% 🙂 Try splitting into smaller methods. 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!

Help us improve this quality report!

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