Passed
Push — main ( d9c4dc...ea73d7 )
by Yohann
01:08
created

pincer_bot.bot   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 67.86 %

Importance

Changes 0
Metric Value
eloc 20
dl 19
loc 28
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A Bot.load_cogs() 5 5 2
A Bot.__init__() 6 6 1
A Bot.on_ready() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
import os
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
from glob import glob
3
from time import perf_counter
4
5
import dotenv
6
from pincer import Client
7
8
9 View Code Duplication
class Bot(Client):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
introduced by
Missing class docstring
Loading history...
10
11
    def __init__(self, *args, **kwargs):
12
        self.load_cogs()
13
14
        dotenv.load_dotenv('.env')
15
        super().__init__(token=os.environ.get('TOKEN'), *args, **kwargs)
16
        self.start_time = perf_counter()
17
18
    def load_cogs(self):
19
        """Load all cogs from the `cogs` directory."""
20
        for cog in glob("pincer_bot/cogs/*.py"):
21
            self.load_cog(cog.replace("/", ".").replace("\\", ".")[:-3])
22
            print("Loaded cogs from", cog)
23
24
    @Client.event
25
    async def on_ready(self):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
26
        print(
27
            f"Logged in as {self.bot} "
28
            f"after {perf_counter() - self.start_time:.3f} seconds."
29
        )
30