language stringclasses 1
value | code stringlengths 407 33.3k | instruction stringclasses 1
value | flaws listlengths 1 17 | flaw_count int64 1 17 |
|---|---|---|---|---|
python | import numpy as np
from tqdm import tqdm, trange
from script.data_handler.Base.BaseDataset import BaseDataset
from script.model.sklearn_like_model.BaseModel import BaseModel
from script.model.sklearn_like_model.Mixin import UnsupervisedMetricCallback
from script.model.sklearn_like_model.NetModule.BaseNetModule imp... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has 11 parameters. Consider using a parameter object to reduce arity.",
"severity": "critical",
"line": 15
},
{
"issue": "Function 'train_AE' has cyclomatic complexity 19 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
... | 5 |
python | from generators.neural_rendering import NeuralRenderer
import math
def next_upsample_step(curriculum, current_step):
# Return the epoch when it will next upsample
current_metadata = extract_metadata(curriculum, current_step)
current_size = current_metadata['img_size']
for curriculum_step in sorted([cs ... | Review this code and list any quality issues. | [
{
"issue": "Function 'next_upsample_step' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 4
},
{
"issue": "Function 'last_upsample_step' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions... | 3 |
python | #!/usr/bin/env python3
import redis
import argparse
import hashlib
from getpass import getpass
r = redis.StrictRedis(host="localhost", port=6379)
parser = argparse.ArgumentParser()
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('--add', action='store_true', help='Adds a service')
group... | Review this code and list any quality issues. | [
{
"issue": "Function 'interactive_update' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 69
},
{
"issue": "Function 'main' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"seve... | 2 |
python | from datetime import datetime
from io import StringIO
from unittest.mock import patch
from django.conf import settings
from django.core import mail
from django.core.management import call_command
from django.test import TestCase
from django.utils import timezone
from main import models
from main.management.commands i... | Review this code and list any quality issues. | [
{
"issue": "Function 'setUp' is 26 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 21
},
{
"issue": "Function 'setUp' is 31 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 90
},
{
... | 4 |
python |
from pygame import Rect
# noinspection PyPackageRequirements
from OpenGL import GL
from albow.openGL.GLViewport import GLViewport
class GLOrtho(GLViewport):
"""
GLOrtho provides an OpenGL drawing area with an orthographic projection.
Using a GLOrtho widget is the same as using a GLViewport, except tha... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has 9 parameters. Consider using a parameter object to reduce arity.",
"severity": "critical",
"line": 22
}
] | 1 |
python | from __future__ import annotations
import os
import itertools
from typing import Any, Optional, TypeVar
import pygame
from gupb.controller import keyboard
from gupb.model import characters
from gupb.model import effects
from gupb.model import games
from gupb.model import tiles
from gupb.model import weapons
pygame.i... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' is 47 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 32
},
{
"issue": "Function 'run' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line... | 3 |
python | from ..base import MultiGridEnv
from .empty import EmptyMultiGrid, EmptyColorMultiGrid
from .doorkey import DoorKeyEnv
from .cluttered import ClutteredMultiGrid
from .goalcycle import ClutteredGoalCycleEnv
from .viz_test import VisibilityTestEnv
from .hallways import HallWaysMultiGrid
from .comm_game import Communicat... | Review this code and list any quality issues. | [
{
"issue": "Function 'register_marl_env' has 9 parameters. Consider using a parameter object to reduce arity.",
"severity": "critical",
"line": 22
},
{
"issue": "Function 'env_from_config' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": ... | 2 |
python | import sys
sys.path.append("../..")
from api.control.PID import PID
from api.control.sensor import sensor
from api.control.robot import robot
import posix_ipc as ipc
import time
import threading
import math
import numpy as np
graphq = ipc.MessageQueue('/graphQueue', ipc.O_CREAT)
mq = ipc.MessageQueue('/keyQueue', ipc... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 21
},
{
"issue": "Function 'run' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 30
... | 4 |
python | import networkx as nx
import numpy as np
import matplotlib.pyplot as plt
import pickle
import math
from dynsimf.models.Model import Model
from dynsimf.models.Model import ModelConfiguration
from dynsimf.models.components.Memory import MemoryConfiguration
from dynsimf.models.components.Memory import MemoryConfiguration... | Review this code and list any quality issues. | [
{
"issue": "Function 'network_update' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 121
}
] | 1 |
python | """ Module for controlling Thorlabs motorized pollarization paddles """
import ctypes
from ctypes import Structure
import time
from pylabnet.utils.logging.logger import LogHandler
#from comtypes.typeinfo import SAFEARRAYABOUND
#enum FT_Status
FT_OK = ctypes.c_short(0x00)
FT_InvalidHandle = ctypes.c_short(0x0)
FT_Dev... | Review this code and list any quality issues. | [
{
"issue": "Function '_configure_functions' is 47 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 157
}
] | 1 |
python | from abc import ABCMeta, abstractmethod
from ..utils.activations import *
class NetworkBase(metaclass=ABCMeta):
def __init__(self, sizes, activation, last_layer, **kwargs):
self.sizes = sizes
self.num_layers = len(sizes)
if activation.lower() == "sigmoid":
self.activation = Sigm... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has cyclomatic complexity 12 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 5
},
{
"issue": "Function '__init__' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line"... | 2 |
python | import keras
import tensorflow as tf
import keras.backend.tensorflow_backend as K
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
# config.gpu_options.per_process_gpu_memory_fraction = 0.9
sess = tf.Session(config=config)
K.set_session(sess)
import os
import sys
sys.path.insert(0, '../')
from models.... | Review this code and list any quality issues. | [
{
"issue": "Function 'main' is 42 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 26
}
] | 1 |
python | """SCons.Tool.rmic
Tool-specific initialization for rmic.
There normally shouldn't be any need to import this module directly.
It will usually be imported through the generic SCons.Tool.Tool()
selection method.
"""
#
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007 The SCons Foundation
#
# Permission is her... | Review this code and list any quality issues. | [
{
"issue": "Function 'emit_rmic_classes' has cyclomatic complexity 13 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 44
},
{
"issue": "Function 'emit_rmic_classes' is 41 lines long. Functions over 25 lines are harder to test and maintain.",
"sever... | 2 |
python | from UnetModel import *
def get_params_dict(logDir):
file = open(logDir, 'r')
logText = file.read()
file.close()
filterText = re.findall('parameters_search : (\w.*)', logText)[2:-2]
splitedText = [item.split(' : ') for item in filterText]
dictParams = dict()
for item in splitedText:
... | Review this code and list any quality issues. | [
{
"issue": "Function 'main_func' is 54 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 20
}
] | 1 |
python | from configparser import ConfigParser
from contextlib import contextmanager
import os
from dotenv import load_dotenv
from mop2.utils.atomic_writes import atomic_write
from mop2.utils.files import change_dir
CONFVARIABLES = "app.config.ini"
OPERATIONSPATH = "../../../data"
TESTVARIABLES = "test.app.config.ini"
TESTIN... | Review this code and list any quality issues. | [
{
"issue": "Function 'create_baseline_configuration' is 67 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 16
}
] | 1 |
python | #!/usr/bin/env python3
#
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
... | Review this code and list any quality issues. | [
{
"issue": "Function 'get_packages' has cyclomatic complexity 16 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 51
},
{
"issue": "Function 'get_projects_mapping' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller function... | 5 |
python | from bilibili import bilibili
import datetime
import time
import asyncio
import traceback
import os
import configloader
import utils
from printer import Printer
class Tasks:
def __init__(self):
fileDir = os.path.dirname(os.path.realpath('__file__'))
file_user = fileDir + "/conf/user.conf"
... | Review this code and list any quality issues. | [
{
"issue": "Function 'link_sign' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 43
},
{
"issue": "Function 'auto_send_gift' has cyclomatic complexity 11 (threshold: 5). Consider breaking it into smaller functions.",
"se... | 3 |
python | # -*- coding: utf-8 -*-
"""
Enforce state for SSL/TLS
=========================
"""
# Import Python Libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import logging
import time
__virtualname__ = "tls"
log = logging.getLogger(__name__)
def __virtual__():
if "tls.cert... | Review this code and list any quality issues. | [
{
"issue": "Function 'valid_certificate' is 35 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 26
},
{
"issue": "Function 'valid_certificate' has 6 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"l... | 2 |
python | """Adding feature vectors
Revision ID: f4249b4ba6fa
Revises: 863114f0c659
Create Date: 2020-11-24 14:43:08.789873
"""
import sqlalchemy as sa
from alembic import op
from mlrun.api.utils.db.sql_collation import SQLCollationUtil
# revision identifiers, used by Alembic.
revision = "f4249b4ba6fa"
down_revision = "86311... | Review this code and list any quality issues. | [
{
"issue": "Function 'upgrade' is 81 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 20
}
] | 1 |
python | import warnings
import numpy as np
from .utils_moments import moments
from .velocity import velocity, ss_estimation
from .utils import (
get_mapper,
get_valid_bools,
get_data_for_kin_params_estimation,
get_U_S_for_velocity_estimation,
)
from .utils import set_velocity, set_param_ss, set_param_kinetic
fr... | Review this code and list any quality issues. | [
{
"issue": "Function '_dynamics' has cyclomatic complexity 29 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 15
},
{
"issue": "Function '_dynamics' is 222 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "criti... | 3 |
python | class DeviceIdentifierType:
FIT = "fit"
TCX = "tcx"
class FITDeviceIdentifier:
def __init__(self, manufacturer, product=None):
self.Type = DeviceIdentifierType.FIT
self.Manufacturer = manufacturer
self.Product = product
class TCXDeviceIdentifier:
def __init__(self, name, productId=None):
self.Type = Devic... | Review this code and list any quality issues. | [
{
"issue": "Function 'FindEquivalentIdentifierOfType' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 33
},
{
"issue": "Function '__init__' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity... | 2 |
python | # --------------------------------------------------------
# Compute metrics for trackers using ground-truth data
# Written by Wang Xueyang (wangxuey19@mails.tsinghua.edu.cn), Version 20200321
# Based on motmetrics (https://github.com/cheind/py-motmetrics/)
# --------------------------------------------------------
im... | Review this code and list any quality issues. | [
{
"issue": "Function 'parse_args' is 41 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 18
},
{
"issue": "Function 'main' has cyclomatic complexity 11 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"... | 3 |
python | MAXIMUM_ARRAY_LENGTH = 1024
def Main(operation, args):
if operation == 'DynamicListTest':
return DynamicListTest()
return False
def DynamicListTest():
dynamicList = DynamicList()
added = DynamicAppend(dynamicList, 1)
assert(added)
count = len(dynamicList["packed"][0]["array"])
a... | Review this code and list any quality issues. | [
{
"issue": "Function 'do_find' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 206
},
{
"issue": "Function 'do_find' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line":... | 2 |
python | import torch
from torch import nn
from torch.nn import functional as F
from torchutils import to_device
class FocalLoss(nn.Module):
"""weighted version of Focal Loss"""
def __init__(self, alpha=.25, gamma=2, device=None):
super(FocalLoss, self).__init__()
self.alpha = torch.tensor([alpha, 1 ... | Review this code and list any quality issues. | [
{
"issue": "Function 'binary_cross_entropy_weighted_focal_loss' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 26
},
{
"issue": "Function 'cross_entropy_focal_loss' has 6 parameters. Consider using a parameter object to reduce arity.",
"se... | 3 |
python | from tornado.web import HTTPError
from ddtrace import config
from ...constants import ANALYTICS_SAMPLE_RATE_KEY
from ...constants import SPAN_MEASURED_KEY
from ...ext import SpanTypes
from ...ext import http
from ...propagation.http import HTTPPropagator
from .constants import CONFIG_KEY
from .constants import REQUES... | Review this code and list any quality issues. | [
{
"issue": "Function 'execute' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 16
},
{
"issue": "Function 'log_exception' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severi... | 2 |
python | #!/usr/bin/python3
# encoding='utf-8'
# author:weibk
# @time:2021/9/23 19:10
import pymysql
import random
con = pymysql.connect(host="localhost",
user="root",
password="123456",
database="db",
charset="utf8")
cursor = con.cursor(c... | Review this code and list any quality issues. | [
{
"issue": "Function 'useradd' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 40
},
{
"issue": "Function 'useradd' is 39 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"l... | 3 |
python | from sys import maxsize
class User:
def __init__(self, firstname=None, lastname=None, address=None, email=None, email2=None, email3=None, user_id=None,
homephone=None, workphone=None, mobilephone=None, additionalphone=None,
all_phones_from_home_page=None, all_emails_from_home_pa... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has 15 parameters. Consider using a parameter object to reduce arity.",
"severity": "critical",
"line": 6
}
] | 1 |
python | # Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | Review this code and list any quality issues. | [
{
"issue": "Function '_check_session' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 50
}
] | 1 |
python | """A module for defining WORKSPACE dependencies required for rules_foreign_cc"""
load("//for_workspace:repositories.bzl", "repositories")
load("//toolchains:toolchains.bzl", "prebuilt_toolchains", "preinstalled_toolchains")
load(
"//tools/build_defs/shell_toolchain/toolchains:ws_defs.bzl",
shell_toolchain_work... | Review this code and list any quality issues. | [
{
"issue": "Function 'rules_foreign_cc_dependencies' has 7 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 11
}
] | 1 |
python | import pandas as pd
import geopandas
import json
import altair as alt
def make_metrics_df():
GEOJSON = 'geojson/wi_map_plan_{}.geojson'
mm_gaps = []
sl_indices = []
efficiency_gaps = []
plan_number = [i for i in range(1,84)]
for i in range(1,84):
plan = geopandas.read_file(GEOJSON.forma... | Review this code and list any quality issues. | [
{
"issue": "Function 'make_metrics_plot' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 22
}
] | 1 |
python | import sys
import os
import json
import azure.functions as func
import google.protobuf as proto
import grpc
# Load dependency manager from customer' context
from azure_functions_worker.utils.dependency import DependencyManager as dm
def main(req: func.HttpRequest) -> func.HttpResponse:
"""This function is an Htt... | Review this code and list any quality issues. | [
{
"issue": "Function 'main' is 29 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 12
}
] | 1 |
python | import sys, fileinput, json
import numpy as np
fir_p = {} # 某字符出现在句首的概率对数 {str: float}
dou_count = {} # 字符的二元出现次数 {(str, str): int}
tri_count = {} # 字符的三元出现次数 {str: {str: {str: int}}}
sin_count = {} # 字符出现计数 {str: int}
pch = {} # 拼音到字符的dict {pinyin: [chs]}
sin_total = 396468407
def preload3():
def add3(dic... | Review this code and list any quality issues. | [
{
"issue": "Function 'run3' has cyclomatic complexity 16 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 91
},
{
"issue": "Function 'run3' is 34 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "critical",
"... | 4 |
python | from typing import List, Optional
import aiosqlite
from btcgreen.util.db_wrapper import DBWrapper
from btcgreen.util.ints import uint32
from btcgreen.wallet.util.wallet_types import WalletType
from btcgreen.wallet.wallet_action import WalletAction
class WalletActionStore:
"""
WalletActionStore keeps track o... | Review this code and list any quality issues. | [
{
"issue": "Function 'create_action' has 8 parameters. Consider using a parameter object to reduce arity.",
"severity": "critical",
"line": 68
}
] | 1 |
python | import math
import random
import geocoder
import gpxpy.geo
from geopy import Point, distance
from s2sphere import CellId, LatLng
from .custom_exceptions import GeneralPogoException
from .util import is_float
DEFAULT_RADIUS = 70
# Wrapper for location
class Location(object):
def __init__(self, locationLookup, geo_k... | Review this code and list any quality issues. | [
{
"issue": "Function 'setLocation' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 34
}
] | 1 |
python | import numpy as np
import pandas as pd
def tanhderiv(K):
"""
used to calculate the derivative of tanh function.
"""
return 1- (np.tanh(K)**2)
def initialisetheta(m,n,nodes,yn):
"""
used to randomly initialise the weights matrix and store it in the
form of a list. Note that the bias term has been directly a... | Review this code and list any quality issues. | [
{
"issue": "Function 'delta_function' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 53
}
] | 1 |
python | from classes.Humanoid import Humanoid
class Player(Humanoid):
def __init__(self, name, room, dmg=1, hp=10):
super().__init__(name, room, dmg, hp)
self.equipped = None
def __str__(self):
return f'{self.name}: ', '{\n', f'\t[\n\t\thp: {self.hp}/{self.max_hp},\n\t\tdmg: {self.dmg}\n\tequ... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 5
}
] | 1 |
python | """Tests for 1-Wire sensor platform."""
from unittest.mock import patch
from pyownet.protocol import Error as ProtocolError
import pytest
from homeassistant.components.onewire.const import (
DEFAULT_SYSBUS_MOUNT_DIR,
DOMAIN,
PLATFORMS,
)
from homeassistant.components.sensor import ATTR_STATE_CLASS, DOMAIN... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_sensors_on_owserver_coupler' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 76
},
{
"issue": "Function 'test_sensors_on_owserver_coupler' is 42 lines long. Functions over 25 lines are harder to te... | 4 |
python | import uuid
from django.test import TestCase, SimpleTestCase
from casexml.apps.case.exceptions import IllegalCaseId
from casexml.apps.case.mock import CaseBlock
from casexml.apps.case.models import CommCareCase
from casexml.apps.case.xform import CaseDbCache
from casexml.apps.case.xml import V2
from corehq.form_process... | Review this code and list any quality issues. | [
{
"issue": "Function 'testStripHistory' is 27 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 94
}
] | 1 |
python | # -*- coding: utf-8 -*-
"""
Salt compatibility code
"""
# pylint: disable=import-error,unused-import,invalid-name,W0231,W0233
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import binascii
import logging
import sys
# Import 3rd-party libs
from salt.exceptions import Sal... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 134
},
{
"issue": "Function '__init__' is 29 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
... | 2 |
python | """Standalone Authenticator."""
import collections
import errno
import logging
import socket
from typing import Any
from typing import Callable
from typing import DefaultDict
from typing import Dict
from typing import Iterable
from typing import List
from typing import Mapping
from typing import Set
from typing import ... | Review this code and list any quality issues. | [
{
"issue": "Function 'cleanup' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 190
}
] | 1 |
python | """ TensorMONK :: layers :: RoutingCapsule """
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from ..activations import Activations
class RoutingCapsule(nn.Module):
r""" Routing capsule from Dynamic Routing Between Capsules.
Implemented -- https://arxiv.org/pdf/1710.098... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has 7 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 26
}
] | 1 |
python | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" Command: .react happy|thinking|waving|wtf|love|confused|dead|sad|dog """
from telethon import events
import random
import asyncio
@borg.on(events.NewMessage(pattern=r"\.react (.*)", outgoing=True))
async def _(event):
if event.fwd_from:
return
input_s... | Review this code and list any quality issues. | [
{
"issue": "Function '_' has cyclomatic complexity 11 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 10
},
{
"issue": "Function '_' is 100 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 10
... | 2 |
python | #!/usr/bin/env python3
from __future__ import unicode_literals
from builtins import bytes, dict, list, int, float, str
import argparse
import json
import sys
import unittest
from reflectrpc.client import RpcClient
from reflectrpc.testing import ServerRunner
server_program = None
class ConformanceTest(unittest.Test... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_conformance' is 154 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 19
}
] | 1 |
python | class Car(object):
def __ini__(self, name, model, car_doors, car_wheels, speed = 0):
if not name:
self.name = "General"
else:
self.name = name
if not model:
self.model = "Gm"
else:
self.mo... | Review this code and list any quality issues. | [
{
"issue": "Function '__ini__' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 3
},
{
"issue": "Function '__ini__' has 6 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 3... | 2 |
python | import math
import rospy
import tf2_ros as tf2
from geometry_msgs.msg import PointStamped
from bitbots_head_behavior.actions.look_at import AbstractLookAt
class SearchRecentBall(AbstractLookAt):
"""
This action looks at the last position the ball has been seen
and starts searching it from this position o... | Review this code and list any quality issues. | [
{
"issue": "Function 'perform' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 65
}
] | 1 |
python | #!/usr/bin/python3
__version__ = '0.0.1' # Time-stamp: <2021-09-25T07:39:16Z>
## Language: Japanese/UTF-8
"""Simulation Buddhism Prototype No.3 x.1 - Death
死亡関連
"""
##
## Author:
##
## JRF ( http://jrf.cocolog-nifty.com/statuses/ (in Japanese))
##
## License:
##
## The author is a Japanese.
##
## I intended th... | Review this code and list any quality issues. | [
{
"issue": "Function 'die_relation' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 44
},
{
"issue": "Function 'die_supporting' has cyclomatic complexity 13 (threshold: 5). Consider breaking it into smaller functions.",
... | 7 |
python | import numpy as np
def build_local_integration_grid_circle(n_quad_points, r_c):
# Guass-Legendre quadrature on the unit disk (by KyoungJoong Kim and ManSuk Song)
if n_quad_points == 1:
w_1 = 3.141592653589793
x_1 = 0.0
quad_point_x = np.array([x_1]) * r_c
quad_point_y = np.a... | Review this code and list any quality issues. | [
{
"issue": "Function 'build_local_integration_grid_circle' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 3
},
{
"issue": "Function 'build_local_integration_grid_circle' is 147 lines long. Functions over 25 lines are harder... | 2 |
python | #!/usr/bin/env python
"""
Copyright 2016 ARM Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to i... | Review this code and list any quality issues. | [
{
"issue": "Function 'verify_output_per_device' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 34
},
{
"issue": "Function 'verify_output_per_device' is 27 lines long. Functions over 25 lines are harder to test and maintain.... | 6 |
python | import sys
from rpython.rtyper.lltypesystem.lltype import *
from rpython.translator.translator import TranslationContext
from rpython.translator.c.database import LowLevelDatabase
from rpython.flowspace.model import Constant, Variable, SpaceOperation
from rpython.flowspace.model import Block, Link, FunctionGraph
from r... | Review this code and list any quality issues. | [
{
"issue": "Function 'dump_on_stdout' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 11
},
{
"issue": "Function 'test_func_simple' is 26 lines long. Functions over 25 lines are harder to test and maintain.",
"severity":... | 2 |
python | #
# Copyright 2017 Canonical Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | Review this code and list any quality issues. | [
{
"issue": "Function 'render_config' is 28 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 305
}
] | 1 |
python | __author__ = 'renhao.cui'
import utilities
from sklearn import cross_validation
import combinedMapping as cm
import modelUtility
def alchemyTrainInfer(alchemy_train, alchemy_test, label_train, label_test, trainProbFlag):
# model from A to B: model[A] = {B: score}
(model, cand, candProb) = cm.mappingTrainer4(al... | Review this code and list any quality issues. | [
{
"issue": "Function 'alchemyTrainInfer' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 7
}
] | 1 |
python | """Tests for perfkitbenchmarker.providers.aws.aws_dynamodb."""
import json
import unittest
from absl import flags
from absl.testing import flagsaver
from absl.testing import parameterized
import mock
from perfkitbenchmarker import errors
from perfkitbenchmarker.providers.aws import aws_dynamodb
from perfkitbenchmarke... | Review this code and list any quality issues. | [
{
"issue": "Function 'testGetResourceMetadata' is 27 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 108
}
] | 1 |
python | from datetime import timedelta
import logging
from django.apps import apps as django_apps
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.contrib.auth import get_user_model
from django.db import transaction
from django.utils import timezone
from django.utils.module... | Review this code and list any quality issues. | [
{
"issue": "Function 'update_or_create_user_and_oidc_profile' is 32 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 78
}
] | 1 |
python | from PyQt5.QtCore import pyqtSignal, QObject, pyqtSlot
from PyQt5.QtWidgets import QVBoxLayout, QHBoxLayout, QLineEdit, QLabel, QPushButton, QGroupBox, QSizePolicy, \
QFormLayout, QWidget, QCheckBox
class MainFunctionAbstract(QGroupBox):
send_data = pyqtSignal(str, dict)
flag_update_signal = pyqtSignal(s... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' is 26 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 90
}
] | 1 |
python | # -*- coding: utf-8 -*-
################################################################################
# Copyright (c), AiiDA team and individual contributors. #
# All rights reserved. #
# This file is part of the AiiDA-wannier90 code. ... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_wannier_default' has 6 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 20
},
{
"issue": "Function 'test_no_kpoint_path' is 27 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
... | 5 |
python | #! /usr/bin/env python
"""API Wrapper for Bitcoin.de Trading API."""
import requests
import time
import json
import hmac
import hashlib
import logging
import codecs
import decimal
import inspect
import urllib
from future.standard_library import install_aliases
install_aliases()
from urllib.parse import urlencode
lo... | Review this code and list any quality issues. | [
{
"issue": "Function 'verify_keys_and_values' has cyclomatic complexity 12 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 37
},
{
"issue": "Function 'send_request' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": ... | 4 |
python | ply_header = '''ply
format ascii 1.0
element vertex %(vert_num)d
property float x
property float y
property float z
property uchar red
property uchar green
property uchar blue
end_header
'''
class PLY_Manip:
def __init__(self, results_dir):
self.dir = results_dir
def insert_header(self, point_cl... | Review this code and list any quality issues. | [
{
"issue": "Function 'insert_point' has 8 parameters. Consider using a parameter object to reduce arity.",
"severity": "critical",
"line": 26
}
] | 1 |
python | """rnn.py
~~~~~~~~~~~~~~
Written by Yong Yu Wen, 2018
(Built using tensorflow-gpu 1.6.0)
A TensorFlow-based many-to-one recurrent neural network specifically
for the classification of MBTI types based on social media posts.
Raw un-processed dataset used for this task can be found at
https://www.kaggle.com/datasnaek/m... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has 8 parameters. Consider using a parameter object to reduce arity.",
"severity": "critical",
"line": 25
},
{
"issue": "Function 'train' has cyclomatic complexity 16 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"l... | 4 |
python | import logging
from django.apps import apps
from django.conf import settings
from zconnect import zsettings
from zconnect.util.general import load_from_module
logger = logging.getLogger(__name__)
class Sender:
"""Abstract interface for sending messages to devices
This will pass a generic Message to the s... | Review this code and list any quality issues. | [
{
"issue": "Function 'to_device' has 7 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 26
},
{
"issue": "Function 'as_device' has 7 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 55
},
{
... | 3 |
python | # -*- coding: utf-8 -*-
import pytest
from h.models import Organization
from h.services.list_organizations import (
ListOrganizationsService,
list_organizations_factory,
)
from h.services.organization import organization_factory
class TestListOrganizations:
def test_returns_organizations_from_all_author... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_returns_organizations_from_all_authorities_if_no_authority_specified' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 14
},
{
"issue": "Function 'test_returns_organizations_for_the_authority_specified' has 6 parameter... | 2 |
python | '''
Created on Nov 29, 2020
@author: manik
'''
'''
File with classes and code which control how a particular person
will move and to where
'''
from src.population import Population
import numpy as np
import src.person_properties_util as idx
class Movement():
"""
Class providing abstraction into each movement o... | Review this code and list any quality issues. | [
{
"issue": "Function 'update_persons' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 18
},
{
"issue": "Function 'out_of_bounds' is 30 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 6... | 2 |
python | import os
import urllib.request
from osgeo import ogr
from mapswipe_workers.definitions import DATA_PATH, CustomError, logger
from mapswipe_workers.project_types.arbitrary_geometry import grouping_functions as g
from mapswipe_workers.project_types.arbitrary_geometry.group import Group
from mapswipe_workers.project_ty... | Review this code and list any quality issues. | [
{
"issue": "Function 'validate_geometries' has cyclomatic complexity 12 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 22
},
{
"issue": "Function 'validate_geometries' is 92 lines long. Functions over 25 lines are harder to test and maintain.",
"s... | 2 |
python | # coding=utf-8
# *** WARNING: this file was generated by the Pulumi SDK Generator. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
import warnings
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union
from ... import _utilities, _tables
from... | Review this code and list any quality issues. | [
{
"issue": "Function 'list_storage_account_sas_tokens' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 60
}
] | 1 |
python | # coding=utf8
# Copyright 2018 JDCLOUD.COM
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed ... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has 6 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 22
}
] | 1 |
python | import threading
from Utils.Utils_function import logMsg
from Sharing.Sharing import sharing1ES, sharing2ES
from Reconstruction.Reconstruction import reconstructionES1, reconstructionES2
from groups import parametres
par = parametres()
PATH_DATA_USERS = par.PATH_DATA_USERS
CHAR_DATA_SPLIT = par.CHAR_DATA_SPLIT
CHAR_M... | Review this code and list any quality issues. | [
{
"issue": "Function 'run' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 32
},
{
"issue": "Function 'run' is 51 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 32... | 2 |
python | from plotly.basedatatypes import BaseTraceHierarchyType
import copy
class Tickfont(BaseTraceHierarchyType):
# color
# -----
@property
def color(self):
"""
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string ... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 144
},
{
"issue": "Function '__init__' is 28 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
... | 3 |
python | from collections import OrderedDict
__author__ = 'kevin'
import socket
from threading import Lock
class LithiumHelper(object):
@staticmethod
def recv_all(sock):
read = ''
try:
data = sock.recv(1024)
read += data
except socket.error, e:
if isinstance(... | Review this code and list any quality issues. | [
{
"issue": "Function 'recv_text' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 48
},
{
"issue": "Function 'recv_line' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity... | 2 |
python | # Copyright Ryan-Rhys Griffiths and Aditya Raymond Thawani 2020
# Author: Ryan-Rhys Griffiths
"""
Property prediction on the photoswitch dataset using Random Forest.
"""
import argparse
import numpy as np
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import train_test_split
from skle... | Review this code and list any quality issues. | [
{
"issue": "Function 'main' is 42 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 17
},
{
"issue": "Function 'main' has 6 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 17
}
] | 2 |
python | """
Tests the execution of forum notification tasks.
"""
import json
import math
from datetime import datetime, timedelta
from unittest import mock
import ddt
from django.contrib.sites.models import Site
from edx_ace.channel import ChannelType, get_channel_for_message
from edx_ace.recipient import Recipient
from edx... | Review this code and list any quality issues. | [
{
"issue": "Function 'setUpClass' is 27 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 73
},
{
"issue": "Function 'create_thread_and_comments' is 48 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor"... | 3 |
python | # This Python file uses the following encoding: utf-8
"""autogenerated by genpy from turtlesim/Pose.msg. Do not edit."""
import sys
python3 = True if sys.hexversion > 0x03000000 else False
import genpy
import struct
class Pose(genpy.Message):
_md5sum = "863b248d5016ca62ea2e895ae5265cf9"
_type = "turtlesim/Pose"
... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 22
}
] | 1 |
python | from __future__ import print_function
import errno
import os
from PIL import Image
import torch
import torch.nn as nn
import re
import json
import pickle as cPickle
import numpy as np
import utils
import h5py
import operator
import functools
from torch._six import string_classes
import torch.nn.functional as F
impor... | Review this code and list any quality issues. | [
{
"issue": "Function 'trim_collate' has cyclomatic complexity 24 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 143
},
{
"issue": "Function 'trim_collate' is 42 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": ... | 2 |
python | # -*- coding: utf-8 -*-
from django.conf import settings
# modify reversions to match our needs if required...
def reversion_register(model_class, fields=None, follow=(), format="json", exclude_fields=None):
"""CMS interface to reversion api - helper function. Registers model for
reversion only if reversion... | Review this code and list any quality issues. | [
{
"issue": "Function 'reversion_register' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 7
}
] | 1 |
python | import string
def z_array(s):
# NOTE:
# Use Z algorithm (Gusfield theorem 1.4.1) to preprocess s.
assert len(s) > 1
z = [len(s)] + [0] * (len(s) - 1)
# Initial comparison for s[1:] with prefix
for i in range(1, len(s)):
if s[i] == s[i - 1]:
z[1] += 1
else:
... | Review this code and list any quality issues. | [
{
"issue": "Function 'z_array' has cyclomatic complexity 11 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 4
},
{
"issue": "Function 'z_array' is 35 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"l... | 2 |
python | '''
Copyright (c) 2013, Battelle Memorial Institute
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions ... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 66
},
{
"issue": "Function '__init__' has 7 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line"... | 2 |
python | #!/usr/bin/env python
# encoding: utf-8
"""A Snippet instance is an instance of a Snippet Definition.
That is, when the user expands a snippet, a SnippetInstance is created
to keep track of the corresponding TextObjects. The Snippet itself is
also a TextObject.
"""
from UltiSnips import _vim
from UltiSnips.position... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has 9 parameters. Consider using a parameter object to reduce arity.",
"severity": "critical",
"line": 23
},
{
"issue": "Function 'update_textobjects' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor... | 2 |
python | """Docstring
"""
import cv2
#import numpy as np
def find_in_face(haarcascade, rec=False):
"""Press 'k' for quit
"""
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
smile_cascade = cv2.CascadeClassifier(haarcascade)
cap = cv2.VideoCapture(0)
if rec:
fourc... | Review this code and list any quality issues. | [
{
"issue": "Function 'find_in_face' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 8
},
{
"issue": "Function 'find_in_face' is 29 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor... | 2 |
python | import torch
import torch.nn as nn
import torch.nn.init as init
from .nets.backbone import HourglassBackbone, SuperpointBackbone
from .nets.junction_decoder import SuperpointDecoder
from .nets.heatmap_decoder import PixelShuffleDecoder
from .nets.descriptor_decoder import SuperpointDescriptor
def get_model(model_cfg... | Review this code and list any quality issues. | [
{
"issue": "Function 'get_model' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 11
},
{
"issue": "Function 'get_model' is 29 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
... | 4 |
python | import numpy as np
import numpy.testing as npt
from dipy.reconst.peaks import default_sphere, peaks_from_model
def test_PeaksAndMetricsDirectionGetter():
class SillyModel(object):
def fit(self, data, mask=None):
return SillyFit(self)
class SillyFit(object):
def __init__(self, m... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_PeaksAndMetricsDirectionGetter' is 35 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 7
}
] | 1 |
python | """Complex Step derivative approximations."""
from __future__ import division, print_function
from itertools import groupby
from six.moves import range
import numpy as np
from openmdao.approximation_schemes.approximation_scheme import ApproximationScheme
from openmdao.utils.name_maps import abs_key2rel_key
DEFAULT... | Review this code and list any quality issues. | [
{
"issue": "Function 'compute_approximations' has cyclomatic complexity 18 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 90
},
{
"issue": "Function 'compute_approximations' is 53 lines long. Functions over 25 lines are harder to test and maintain.... | 5 |
python | """
base16vlq.py
base16 unsigned variable length quantity (VLQ)
based on
https://gist.github.com/mjpieters/86b0d152bb51d5f5979346d11005588b
https://github.com/Rich-Harris/vlq
to encode *signed* integers, we would need _abc_len == 17
python -c $'from base16vlq import encode\nfor n in range(0, 64):\n print(f"{n:3d}... | Review this code and list any quality issues. | [
{
"issue": "Function 'encode' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 82
},
{
"issue": "Function '_test' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "min... | 2 |
python | # Copyright 2018 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | Review this code and list any quality issues. | [
{
"issue": "Function '_operator_and_matrix' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 40
}
] | 1 |
python | import enum
from queue import Queue
class Animal(enum.Enum):
cat = 'cat'
dog = 'dog'
class AnimalShelter:
def __init__(self):
self.cats = Queue()
self.dogs = Queue()
self.pos = 0
# Time complexity: O(1)
# Space complexity: O(1)
def enqueue(self, animal: Animal):
... | Review this code and list any quality issues. | [
{
"issue": "Function 'dequeue' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 30
}
] | 1 |
python | """The Fast Gradient Method attack."""
import numpy as np
import tensorflow as tf
def fast_gradient_method(model_fn, x, eps, ord, clip_min=None, clip_max=None, y=None,
targeted=False, sanity_checks=False):
"""
Tensorflow 2.0 implementation of the Fast Gradient Method.
:param model_fn: ... | Review this code and list any quality issues. | [
{
"issue": "Function 'fast_gradient_method' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 7
},
{
"issue": "Function 'fast_gradient_method' has 9 parameters. Consider using a parameter object to reduce arity.",
"seve... | 2 |
python | import inspect
import sys
from pathlib import Path
from types import TracebackType
from typing import NoReturn, Optional, Union
import rich.console
import typer
from . import Severity, Verbosity
from .config import config
__all__ = ["error", "warning", "info", "debug"]
COLOR_MAP = {
Severity.ERROR: "red",
... | Review this code and list any quality issues. | [
{
"issue": "Function 'error' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 31
},
{
"issue": "Function 'warning' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "mi... | 3 |
python | """
Woopra template tags and filters.
"""
from __future__ import absolute_import
import json
import re
from django.conf import settings
from django.template import Library, Node, TemplateSyntaxError
from analytical.utils import (
disable_html,
get_identity,
get_required_setting,
get_user_from_contex... | Review this code and list any quality issues. | [
{
"issue": "Function '_get_visitor' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 79
}
] | 1 |
python | #
# Copyright 2014 OpenStack Foundation. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless req... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_load_certificates' is 28 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 143
},
{
"issue": "Function 'test_map_cert_tls_container' is 30 lines long. Functions over 25 lines are harder to test and maintain.",
"seve... | 2 |
python | from tensorize import *
class InceptionResnetV1(Model):
def inference(self, inputs, output):
stem(inputs, outputs)
for x in xrange(4):
inceptionA()
reductionA()
for x in xrange(7):
inceptionB()
reductionB()
for x in xrange(3):
... | Review this code and list any quality issues. | [
{
"issue": "Function 'stem' is 27 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 59
}
] | 1 |
python | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from openpyxl.worksheet.worksheet import Worksheet
COLUMNS = {"A": 20,
"B": 10,
"C": 10,
"D": 10,
"E": 10,
"F": 10,
"G": 10,
"H": 10,
"I": 10}
class RankingReportWriter(object):
... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 19
},
{
"issue": "Function '_write_value' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 45
},
{
... | 3 |
python | from django.urls import reverse
from rest_framework import status
from main.tests.api import helpers
class TestPermissions(helpers.BaseUserTestCase):
"""
Test Permissions
Get: authenticated
Update: admin
Create: admin
Delete: admin
"""
def test_get(self):
urls = [
... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_get' is 28 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 16
},
{
"issue": "Function 'test_create' is 33 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 45
... | 5 |
python | # Copyright (c) 2017 Sony Corporation. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | Review this code and list any quality issues. | [
{
"issue": "Function '__forward_recursive' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 54
},
{
"issue": "Function 'get_backward_sequence' has cyclomatic complexity 11 (threshold: 5). Consider breaking it into smaller fun... | 9 |
python | # -*- coding: utf-8 -*-
import pandas as pd
class Model():
"""Abstract model class.
This is the top-level class and should not be used directly.
Instead this class is inherited by other more specialised model classes.
"""
def __init__(self):
""
self._inputs=Inputs()
... | Review this code and list any quality issues. | [
{
"issue": "Function 'set_timestamps' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 64
}
] | 1 |
python | """
sample code for LLOCK, SLOCK, LSLOCK
application the method to advection model (periodic boundary condition)
"""
import os, sys
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sys.path.append("..")
from pyassim import KalmanFilter, LocalLOCK, SpatiallyUniformLOCK, LSLOCK,\
... | Review this code and list any quality issues. | [
{
"issue": "Function 'main' is 68 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 17
}
] | 1 |
python | import robin_stocks as r
import pandas as pd
import numpy as np
import ta as ta
from pandas.plotting import register_matplotlib_converters
from ta import *
from misc import *
from tradingstats import *
#Log in to Robinhood
login = r.login('YOUR_EMAIL','YOUR_PASSWORD')
#Safe divide by zero division function
def safe_d... | Review this code and list any quality issues. | [
{
"issue": "Function 'get_last_crossing' has cyclomatic complexity 20 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 81
},
{
"issue": "Function 'get_last_crossing' is 29 lines long. Functions over 25 lines are harder to test and maintain.",
"se... | 5 |
python | #!/usr/bin/env python3
'''
diffinfo.py
Copyright 2012-2017 Codinuum Software Lab <http://codinuum.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licen... | Review this code and list any quality issues. | [
{
"issue": "Function 'read_delete_insert_info' has cyclomatic complexity 13 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 60
},
{
"issue": "Function 'read_delete_insert_info' is 62 lines long. Functions over 25 lines are harder to test and maintain."... | 4 |
python | class ServiceCentre(object):
"""
An information store for each service centre in the queueing network.
Contains all information that is independent of customer class:
- number of servers
- queueing capacity
- server schedules + preemtion status
- class change matrix
"""
def _... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has 7 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 10
},
{
"issue": "Function '__init__' has 7 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 39
}
] | 2 |
python | "" "Este módulo implementa o objeto jogador (sprite) para o Progmind" ""
from src.animation import Animation
from src.animated_sprite import AnimatedSprite
from src.time_bonus import TimeBonus
import src.game_functions as gf
import pygame
import time
class Player(AnimatedSprite):
"""Objeto de jogador"""
def ... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' is 27 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 13
},
{
"issue": "Function '__init__' has 6 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 13
},
{
... | 8 |
python | import argparse
import asyncio
import html
import json
import logging
import os
import textwrap
import time
import xmltodict
from aiohttp import ClientSession, ClientConnectorError, ServerDisconnectedError, ContentTypeError
from articlemeta.client import RestfulClient
from datetime import datetime
from json import JSO... | Review this code and list any quality issues. | [
{
"issue": "Function 'extract_attrs' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 55
},
{
"issue": "Function '_extract_cit_attrs' has cyclomatic complexity 18 (threshold: 5). Consider breaking it into smaller functions.",... | 9 |
python | #!/usr/bin/env python
import json
import os
import re
import sys
import tarfile
from urllib.request import urlretrieve
def main():
# Read in given out_file and create target directory for file download
with open(sys.argv[1]) as fh:
params = json.load(fh)
target_directory = params['output_data'][0... | Review this code and list any quality issues. | [
{
"issue": "Function 'main' is 33 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 11
}
] | 1 |
python | #!/usr/bin/env python3
import sys
from PySide2 import QtCore, QtWidgets, QtGui
from os.path import exists, join, abspath
from os import remove
import tweepy
from auth.auth import AuthData
from tweet.tweet import getTweetsKeyword, tweetRandom, OutputerInterface
import types
class AuthDataInput(QtWidgets.QWidget):
d... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' is 32 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 12
},
{
"issue": "Function '__init__' is 42 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 66
}... | 4 |
python | # Create your views here.
from rest_framework.views import APIView
from .serializers import UserSerializer, LoginSerializer
from ..utils.helpers.json_helpers import generate_response, raise_error, add_token_to_response, validate_url, validate_confirmation_request
from ..utils import success_messages
from ..utils.error... | Review this code and list any quality issues. | [
{
"issue": "Function 'post' is 28 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 29
},
{
"issue": "Function 'post' is 29 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 85
},
{
... | 4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.