tjcsl/cslbot

View on GitHub

Showing 1,460 of 1,460 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

Severity: Major
Found in cslbot/alembic/versions/2ee084539c59_no_timezones.py and 1 other location - About 2 days to fix
cslbot/alembic/versions/243c9cf0eb7d_use_datetime_not_float.py on lines 0..37

Similar blocks of code found in 2 locations. Consider refactoring.
Open

Severity: Major
Found in cslbot/alembic/versions/243c9cf0eb7d_use_datetime_not_float.py and 1 other location - About 2 days to fix
cslbot/alembic/versions/2ee084539c59_no_timezones.py on lines 0..37

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

    Similar blocks of code found in 6 locations. Consider refactoring.
    Open

    @mock.patch('cslbot.commands.wisdom.get')
    def test_wisdom_invalid(self, mock_get):
    """Test wisdom with no results."""
    with open(join(dirname(__file__), 'data', 'wisdom_jibberjabber.xml')) as test_data_file:
    mock_get.return_value = mock.Mock(content=test_data_file.read().encode())
    Severity: Major
    Found in test/cslbot_test.py and 5 other locations - About 6 hrs to fix
    test/cslbot_test.py on lines 110..118
    test/cslbot_test.py on lines 135..146
    test/cslbot_test.py on lines 180..189
    test/cslbot_test.py on lines 191..198
    test/cslbot_test.py on lines 207..214

    Similar blocks of code found in 6 locations. Consider refactoring.
    Open

    @mock.patch('cslbot.commands.wisdom.get')
    def test_wisdom_valid(self, mock_get):
    """Test a valid wisdom lookup."""
    with open(join(dirname(__file__), 'data', 'wisdom_asimov.xml')) as test_data_file:
    mock_get.return_value = mock.Mock(content=test_data_file.read().encode())
    Severity: Major
    Found in test/cslbot_test.py and 5 other locations - About 6 hrs to fix
    test/cslbot_test.py on lines 110..118
    test/cslbot_test.py on lines 148..156
    test/cslbot_test.py on lines 180..189
    test/cslbot_test.py on lines 191..198
    test/cslbot_test.py on lines 207..214

    Similar blocks of code found in 6 locations. Consider refactoring.
    Open

    @mock.patch('cslbot.commands.define.get')
    def test_definition_invalid(self, mock_get):
    """Test an invalid definition."""
    with open(join(dirname(__file__), 'data', 'define_potatwo.xml')) as test_data_file:
    mock_get.return_value = mock.Mock(content=test_data_file.read().encode())
    Severity: Major
    Found in test/cslbot_test.py and 5 other locations - About 6 hrs to fix
    test/cslbot_test.py on lines 110..118
    test/cslbot_test.py on lines 135..146
    test/cslbot_test.py on lines 148..156
    test/cslbot_test.py on lines 180..189
    test/cslbot_test.py on lines 207..214

    Similar blocks of code found in 6 locations. Consider refactoring.
    Open

    @mock.patch('cslbot.commands.zipcode.get')
    def test_zipcode_valid(self, mock_get):
    """Test a correct zip code."""
    with open(join(dirname(__file__), 'data', 'zipcode_12345.xml')) as test_data_file:
    mock_get.return_value = mock.Mock(content=test_data_file.read().encode())
    Severity: Major
    Found in test/cslbot_test.py and 5 other locations - About 6 hrs to fix
    test/cslbot_test.py on lines 135..146
    test/cslbot_test.py on lines 148..156
    test/cslbot_test.py on lines 180..189
    test/cslbot_test.py on lines 191..198
    test/cslbot_test.py on lines 207..214

    Similar blocks of code found in 6 locations. Consider refactoring.
    Open

    @mock.patch('cslbot.commands.define.get')
    def test_definition_valid(self, mock_get):
    """Test a valid definition."""
    with open(join(dirname(__file__), 'data', 'define_potato.xml')) as test_data_file:
    mock_get.return_value = mock.Mock(content=test_data_file.read().encode())
    Severity: Major
    Found in test/cslbot_test.py and 5 other locations - About 6 hrs to fix
    test/cslbot_test.py on lines 110..118
    test/cslbot_test.py on lines 135..146
    test/cslbot_test.py on lines 148..156
    test/cslbot_test.py on lines 191..198
    test/cslbot_test.py on lines 207..214

    Similar blocks of code found in 6 locations. Consider refactoring.
    Open

    @mock.patch('cslbot.commands.define.get')
    def test_definition_invalid_index(self, mock_get):
    """Test an invalid definition index."""
    with open(join(dirname(__file__), 'data', 'define_potato.xml')) as test_data_file:
    mock_get.return_value = mock.Mock(content=test_data_file.read().encode())
    Severity: Major
    Found in test/cslbot_test.py and 5 other locations - About 6 hrs to fix
    test/cslbot_test.py on lines 110..118
    test/cslbot_test.py on lines 135..146
    test/cslbot_test.py on lines 148..156
    test/cslbot_test.py on lines 180..189
    test/cslbot_test.py on lines 191..198

    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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      def upgrade():
      if op.get_bind().dialect.name == 'sqlite':
      with op.batch_alter_table('quotes') as batch_op:
      batch_op.add_column(sa.Column('accepted', sa.Integer(), nullable=True))
      batch_op.drop_column('approved')
      Severity: Major
      Found in cslbot/alembic/versions/55efdbb748c_merge_pending.py and 1 other location - About 4 hrs to fix
      cslbot/alembic/versions/55efdbb748c_merge_pending.py on lines 28..34

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      def downgrade():
      if op.get_bind().dialect.name == 'sqlite':
      with op.batch_alter_table('quotes') as batch_op:
      batch_op.add_column(sa.Column('approved', sa.Integer(), nullable=True))
      batch_op.drop_column('accepted')
      Severity: Major
      Found in cslbot/alembic/versions/55efdbb748c_merge_pending.py and 1 other location - About 4 hrs to fix
      cslbot/alembic/versions/55efdbb748c_merge_pending.py on lines 19..25

      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

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      def test_errno_valid_number(self):
      """Test errno number -> name mapping."""
      calls = self.send_msg('pubmsg', 'testnick', '#test-channel', ['!errno 75'])
      output = 'Please install gcc.' if os.name == 'nt' else '#define EOVERFLOW 75'
      self.assertEqual(calls, [('testBot', '#test-channel', 0, output, 'privmsg', self.server),
      Severity: Major
      Found in test/cslbot_test.py and 2 other locations - About 4 hrs to fix
      test/cslbot_test.py on lines 235..240
      test/cslbot_test.py on lines 261..268

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      def test_errno_invalid_name(self):
      """Test errno run with an invalid name."""
      calls = self.send_msg('pubmsg', 'testnick', '#test-channel', ['!errno ENOPANTS'])
      output = 'Please install gcc.' if os.name == 'nt' else 'ENOPANTS not found in errno.h'
      self.assertEqual(calls, [('testBot', '#test-channel', 0, output, 'privmsg', self.server),
      Severity: Major
      Found in test/cslbot_test.py and 2 other locations - About 4 hrs to fix
      test/cslbot_test.py on lines 228..233
      test/cslbot_test.py on lines 261..268

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      class SignalTest(BotTest):
       
      def test_signal_valid(self):
      """Test signal, basic check only since errno covers most of the backend."""
      calls = self.send_msg('pubmsg', 'testnick', '#test-channel', ['!signal 9'])
      Severity: Major
      Found in test/cslbot_test.py and 2 other locations - About 4 hrs to fix
      test/cslbot_test.py on lines 228..233
      test/cslbot_test.py on lines 235..240

      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
      Severity
      Category
      Status
      Source
      Language