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

Logic? #14

Open
chr3st5an opened this issue Sep 15, 2022 · 3 comments
Open

Logic? #14

chr3st5an opened this issue Sep 15, 2022 · 3 comments

Comments

@chr3st5an
Copy link

chr3st5an commented Sep 15, 2022

There are so many issues in this code, I am shocked!

First of all, the LICENSE file states out that the given project is licensed under the
GNU General Public License v3.0 while the readme.md says it is licensed under
the MIT license?

Now, the code itself is full of issues:

  1. PEP8: The code clearly breaks the style convention specified by PEP8

    • inline imports of multiple packages
    • unused import multiprocessing
    • missing 2 empty lines between functions and classes
    • wrong type annotations
      • inconvenient use of type annotations
    • raw except clause
    • and so on
  2. threading.Lock is completely misused

def printer(self, color, status, code):
    threading.Lock().acquire()
    print(f"{color} {status} > {Fore.RESET}discord.gift/{code}")

This code is not thread safe as the Lock is created within that method, which means that different threads will create
different Lock instances, making this line of code completely useless. Better would be:

# global variable
lock = threading.Lock()


def safe_print() -> None:
    with lock:
        print("hi")
  1. What is that?
"".join(random.choice("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890") for _ in range(16))

rewrite as:

from string import ascii_letters, digits
import random


"".join(random.choices(ascii_letters + digits, k=16))
  1. Files are opened explicitly with the r parameter although it is the default parameter value

    • open("blah", "r") == open("blah")
  2. Why so much work?

 def proxies_count(self):
        proxies_list = 0
        with open('config/proxies.txt', 'r') as file:
            proxies = [line.strip() for line in file]
        
        for _ in proxies:
            proxies_list += 1
        
        return int(proxies_list)

# Is the same as

def proxy_count(self) -> int:
    with open("config/proxies.txt") as file:
        return len(file.readlines())
  1. Only one thread is running (always one!!!):
threading.Thread(target=DNG.run(), args=()).start()

look at target! You are calling run instead of passing the method itself to target. That means that you execute the method in the current thread instead of the new thread that you are trying to create there, essentially blocking the while loop and hence blocking the creation of new threads.

@yrifl
Copy link

yrifl commented Sep 17, 2022

You are an expert!

@loggerbeamtest
Copy link

this is fake ong

@danilwhale
Copy link

bro 💀

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

No branches or pull requests

4 participants