tjcsl/cslbot

View on GitHub

Showing 175 of 1,460 total issues

File handler.py has 533 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright (C) 2013-2018 Samuel Damashek, Peter Foley, James Forcier, Srijay Kasturi, Reed Koser, Christopher Reffett, and Tris Wilson
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
Severity: Major
Found in cslbot/helpers/handler.py - About 1 day to fix

    Function cmd has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

    def cmd(send, msg, args):
    """Slap somebody.
     
    Syntax: {command} <nick> [for <reason>]
     
     
    Severity: Minor
    Found in cslbot/commands/slap.py - About 6 hrs to fix

    Function cmd has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

    def cmd(send, msg, args):
    """Gets scores.
     
    Syntax: {command} <--high|--low|nick>
     
     
    Severity: Minor
    Found in cslbot/commands/score.py - About 5 hrs to fix

    BotHandler has 36 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class BotHandler:
     
    def __init__(self, config: configparser.ConfigParser, connection: irc.client.ServerConnection, channels: list[str], confdir: str, idx: int):
    """Set everything up.
     
     
    Severity: Minor
    Found in cslbot/helpers/handler.py - About 4 hrs to fix

      Function cmd has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

      def cmd(send, msg, args):
      """Microwaves something.
       
      Syntax: {command} <level> <target>
       
       
      Severity: Minor
      Found in cslbot/commands/microwave.py - About 4 hrs to fix

      Function cmd has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

      def cmd(send, msg, args):
      """Handles quotes.
      Syntax: {command} <number|nick>, !quote --add <quote> --nick <nick> (--approve), !quote --list, !quote --delete <number>, !quote --edit <number> <quote> --nick <nick>
      !quote --search (--offset <num>) <number>
      """
      Severity: Minor
      Found in cslbot/commands/quote.py - About 4 hrs to fix

      Function build_rows has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

      def build_rows(cursor, length, markov, initial_run):
      table = Babble if length == 1 else Babble2
      data = []
      count_source = collections.defaultdict(int)
      count_target = collections.defaultdict(int)
      Severity: Minor
      Found in cslbot/helpers/babble.py - About 3 hrs to fix

      Function cmd has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

      def cmd(send, msg, args):
      """Files a github issue or gets a open one.
       
      Syntax: {command} <title [--desc description]|--get <number>>
       
       
      Severity: Minor
      Found in cslbot/commands/issue.py - About 3 hrs to fix

      Function handle_show has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

      def handle_show(args):
      if args.cmd == "guarded":
      if args.handler.guarded:
      args.send(", ".join(args.handler.guarded))
      else:
      Severity: Minor
      Found in cslbot/helpers/control.py - About 3 hrs to fix

      File textutils.py has 324 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # Copyright (C) 2013-2018 Samuel Damashek, Peter Foley, James Forcier, Srijay Kasturi, Reed Koser, Christopher Reffett, and Tris Wilson
      #
      # This program is free software; you can redistribute it and/or
      # modify it under the terms of the GNU General Public License
      # as published by the Free Software Foundation; either version 2
      Severity: Minor
      Found in cslbot/helpers/textutils.py - About 3 hrs to fix

        Function cmd has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

        def cmd(send, msg, args):
        """Gets stats.
         
        Syntax: {command} <--high|--low|--userhigh|--nick <nick>|command>
         
         
        Severity: Minor
        Found in cslbot/commands/stats.py - About 3 hrs to fix

        File cslbot_test.py has 297 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        #!/usr/bin/env python3
        # Copyright (C) 2013-2018 Samuel Damashek, Peter Foley, James Forcier, Srijay Kasturi, Reed Koser, Christopher Reffett, and Tris Wilson
        #
        # This program is free software; you can redistribute it and/or
        # modify it under the terms of the GNU General Public License
        Severity: Minor
        Found in test/cslbot_test.py - About 3 hrs to fix

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

          def build_msg(cursor, speaker, length, start):
          table = Babble if length == 1 else Babble2
          location = 'target' if speaker.startswith(('#', '+', '@')) else 'source'
          # handle arguments that end in '\', which is valid in irc, but causes issues with sql.
          escaped_speaker = escape(speaker)
          Severity: Minor
          Found in cslbot/commands/babble.py - About 3 hrs to fix

          Function handle_msg has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

          def handle_msg(self, c, e):
          """The Heart and Soul of IrcBot."""
           
          if e.type not in ['authenticate', 'error', 'join', 'part', 'quit']:
          nick = e.source.nick
          Severity: Minor
          Found in cslbot/helpers/handler.py - About 2 hrs to fix

          Function migrate_config has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

          def migrate_config(config_file: str, config_obj: configparser.ConfigParser, send: Callable[[str], None]) -> None:
          example_obj = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
          example_obj.read_string(resources.files('cslbot.static').joinpath('config.example').read_text())
          modified = False
           
           
          Severity: Minor
          Found in cslbot/helpers/config.py - About 2 hrs to fix

          Function build_markov has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          def build_markov(cursor, cmdchar, ctrlchan, speaker=None, initial_run=False, debug=False):
          """Builds a markov dictionary."""
          if initial_run:
          cursor.query(Babble_last).delete()
          lastrow = cursor.query(Babble_last).first()
          Severity: Minor
          Found in cslbot/helpers/babble.py - About 2 hrs to fix

          Function init has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          def init(confdir="/etc/cslbot"):
          """The bot's main entry point.
           
          | Initialize the bot and start processing messages.
           
           
          Severity: Minor
          Found in cslbot/helpers/core.py - About 2 hrs to fix

          Function handle_enable has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          def handle_enable(args):
          if args.cmd == "kick":
          if args.handler.kick_enabled:
          args.send("Kick already enabled.")
          else:
          Severity: Minor
          Found in cslbot/helpers/control.py - About 2 hrs to fix

          Function get_weather has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          def get_weather(cmdargs, send, apikey):
          if cmdargs.string.startswith("-"):
          data = get(f'http://api.wunderground.com/api/{apikey}/conditions/q/{cmdargs.string[1:]}.json').json()
          if 'current_observation' in data:
          data = {
          Severity: Minor
          Found in cslbot/commands/weather.py - About 2 hrs to fix

          File control.py has 274 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # Copyright (C) 2013-2018 Samuel Damashek, Peter Foley, James Forcier, Srijay Kasturi, Reed Koser, Christopher Reffett, and Tris Wilson
          #
          # This program is free software; you can redistribute it and/or
          # modify it under the terms of the GNU General Public License
          # as published by the Free Software Foundation; either version 2
          Severity: Minor
          Found in cslbot/helpers/control.py - About 2 hrs to fix
            Severity
            Category
            Status
            Source
            Language