Psywerx/botko

View on GitHub

Showing 13 of 21 total issues

Function _handle_mentions has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def _handle_mentions(self, channel, nick, msg):
        msg_lower = msg.lower()
        mentions = set()
        offline_mentions = set()

Severity: Minor
Found in src/plugins/psywerx_groups.py - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function fact has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def fact(self, tokens, channel):
        try:
            def pf(number):
                factors = []
                d = 2
Severity: Minor
Found in src/plugins/psywerx_karma.py - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function _karma has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def _karma(self, tokens, channel):
        if len(tokens) != 1:
            response = self.request(channel, 'irc/karma_nick', {})
            if not response:
                msg = "Sorry, could not get karmas."
Severity: Minor
Found in src/plugins/psywerx_karma.py - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function stop has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def stop(self):
        """Stop the daemon."""
        # Get the pid from the pidfile
        try:
            pf = file(self.pidfile, 'r')
Severity: Minor
Found in src/daemon.py - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function handle_message has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def handle_message(self, channel, nick, msg, line=None):
        msg_lower = msg.lower()
        self.handle_tokens(channel, msg,
                           ('karma', 'karmas', 'leaderboard',
                            'upboats', 'upvotes', 'stats',), self._karma)
Severity: Minor
Found in src/plugins/psywerx_karma.py - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function _download_image has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def _download_image(self, url):
        """Download image in a temporary directory and return its path."""
        try:
            extension = os.path.splitext(url)[1]
            response = requests.get(url, stream=True)
Severity: Minor
Found in src/plugins/nsfw_image_detector.py - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function _process_images has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def _process_images(self, urls):
        """
        Download all the images and return links which include potentially NSFW
        content.
        """
Severity: Minor
Found in src/plugins/nsfw_image_detector.py - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function _read_websites has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def _read_websites(self, channel, msg):
        links = regex.WEB_URL.findall(msg)
        for link in links:
            if [r for r in __all_non_web__ if r.search(link)]:
                continue
Severity: Minor
Found in src/plugins/read_links.py - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Avoid too many return statements within this function.
Open

            return 'NICK_IN_USE'
Severity: Major
Found in src/logic.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return action.upper()
    Severity: Major
    Found in src/logic.py - About 30 mins to fix

      Function _handle_actions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def _handle_actions(self, channel, nick, msg):
              msg_lower = msg.lower()
              for action in self.actions:
                  if msg_lower.startswith(action):
                      params = {'nick': nick}
      Severity: Minor
      Found in src/plugins/psywerx_groups.py - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function _get_image_urls has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_image_urls(self, urls):
              """
              Filter urls to returns only image urls.
      
              Contains url transformers for a few common image sharers.
      Severity: Minor
      Found in src/plugins/nsfw_image_detector.py - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function _get_action_code has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_action_code(line):
              if line.startswith('ERROR'):
                  raise Exception('Unknown IRC error in line: ' + line)
              if line.startswith('PING'):
                  return 'PING'
      Severity: Minor
      Found in src/logic.py - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Severity
      Category
      Status
      Source
      Language