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 Starbot ⭐ refactored ancker010/exabgp-flowspec-generator #1

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

Conversation

sourcery-ai-bot
Copy link

Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨

Here's your pull request refactoring your most popular Python repo.

If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.

Review changes via command line

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

git fetch https://github.com/sourcery-ai-bot/exabgp-flowspec-generator master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Comment on lines -17 to +20
subnet = IPv4Network("192.168.0.0/16")
subnet = IPv4Network("192.168.0.0/16")
bits = getrandbits(subnet.max_prefixlen - subnet.prefixlen)
addr = IPv4Address(subnet.network_address + bits)
addr_str = str(addr)
return addr_str
return str(addr)
Copy link
Author

Choose a reason for hiding this comment

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

Function genipv4 refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -27 to +26
addr_str6 = str(addr6)
return addr_str6
return str(addr6)
Copy link
Author

Choose a reason for hiding this comment

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

Function genipv6 refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -33 to +36
flow_types = []
flow_types.append(
"announce flow route { match { source " + genipv4() + "/32; destination 192.168.255.10/32; destination-port =" + str(random.randint(1024, 65530)) + "; protocol tcp; } then { rate-limit " + str(random.randint(9600, 51200)) + "; } }")
flow_types = [
"announce flow route { match { source " + genipv4() +
"/32; destination 192.168.255.10/32; destination-port =" + str(
random.randint(1024, 65530)) + "; protocol tcp; } then { rate-limit " +
str(random.randint(9600, 51200)) + "; } }"
]
Copy link
Author

Choose a reason for hiding this comment

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

Function genflows refactored with the following changes:

  • Merge append into list assignment

Comment on lines -48 to +54
flow_types6 = []
flow_types6.append(
"announce flow route { match { source " + genipv6() + "/128; destination 2001:DB8:beef:cafe::1/128; destination-port =" + str(random.randint(1024, 65530)) + "; protocol tcp; } then { rate-limit " + str(random.randint(9600, 51200)) + "; } }")
flow_types6 = [
"announce flow route { match { source " + genipv6() +
"/128; destination 2001:DB8:beef:cafe::1/128; destination-port =" + str(
random.randint(1024, 65530)) + "; protocol tcp; } then { rate-limit " +
str(random.randint(9600, 51200)) + "; } }"
]
Copy link
Author

Choose a reason for hiding this comment

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

Function genflows6 refactored with the following changes:

  • Merge append into list assignment

Comment on lines -66 to +74
for x in range(0, count):
for _ in range(count):
flows = genflows()
messages.append(random.choice(flows))

for x in range(0, count):
for x in range(count):
Copy link
Author

Choose a reason for hiding this comment

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

Lines 66-70 refactored with the following changes:

  • Replace range(0, x) with range(x)
  • Replace unused for index with underscore

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.

None yet

1 participant