language stringclasses 1
value | code stringlengths 407 33.3k | instruction stringclasses 1
value | flaws listlengths 1 17 | flaw_count int64 1 17 |
|---|---|---|---|---|
python | import torch
import numpy as np
import SimpleITK as sitk
from Phys_Seg.data_loading import load_and_preprocess, save_segmentation_nifti, read_file, save_img
from Phys_Seg.predict_case import predict_phys_seg, physics_preprocessing, image_preprocessing
import importlib
from Phys_Seg.utils import postprocess_prediction, ... | Review this code and list any quality issues. | [
{
"issue": "Function 'run_phys_seg' has cyclomatic complexity 13 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 21
},
{
"issue": "Function 'run_phys_seg' is 49 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "maj... | 3 |
python | import struct
from collections import namedtuple
from StringIO import StringIO
# Magic string expected at the start of the file to verify it's LZO
_LZO_MAGIC = bytearray("\x89LZO\x00\r\n\x1a\n")
_COMPRESSION_CHECKSUMS = (0x02, 0x200) # ADLER32 CRC32
_DECOMPRESSION_CHECKSUMS = (0x01, 0x100) # ADLER32 CRC32
def _pa... | Review this code and list any quality issues. | [
{
"issue": "Function '_parse_header' has cyclomatic complexity 10 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 12
},
{
"issue": "Function '_parse_header' is 32 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "m... | 2 |
python | # Copyright 2011 OpenStack Foundation
#
# 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 a... | Review this code and list any quality issues. | [
{
"issue": "Function '_vpn_dict' has cyclomatic complexity 10 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 73
},
{
"issue": "Function '_vpn_dict' is 30 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
... | 2 |
python | # Copyright 2012 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 requ... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_verify_created_server_ephemeral_disk' is 37 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 264
}
] | 1 |
python | import random
def name_to_number(name):
if(name=='rock'):
return 0
elif(name=='Spock'):
return 1
elif(name=='paper'):
return 2
elif(name=='lizard'):
return 3
elif(name=='scissors'):
return 4
else:
return name,"is an invalid name"
def ... | Review this code and list any quality issues. | [
{
"issue": "Function 'name_to_number' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 2
},
{
"issue": "Function 'number_to_name' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
... | 3 |
python | """
这份代码使用 Q learning 算法训练并运行俄罗斯方块游戏 ai。其中简化状态空间的方法可参考论文 Adapting Reinforcement Learning to Tetris
"""
import numpy as np
from game import *
sub_well = 4
base = 7
def getStateIndex(field_width, field_height, field_map):
"""
因为每一列有 7 种不同的情况,所以采用七进制数来作为状态索引
"""
temp = [0 for _ in range(field_width)]... | Review this code and list any quality issues. | [
{
"issue": "Function 'getStateIndex' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 14
},
{
"issue": "Function 'dropBlock' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
... | 8 |
python | class VatNumberCheckResult(object):
"""Result of a VAT number validation check.
:ivar is_valid:
Boolean value indicating if the checked VAT number was deemed to be
valid. ``True`` if the VAT number is valid or ``False`` if the VAT
number is positively invalid.
:ivar log_lines:
... | 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": 14
}
] | 1 |
python | """
Author : nkalyan🤠
implementing Python Scripts on reading and returning the name no of mails that sent each day in week
and plot/display them in bar graph
I wrote code In counting to count the number of emails sent by each distinct user. That code may be helpful for this assignment.
"""
import matplotlib.py... | Review this code and list any quality issues. | [
{
"issue": "Function 'pop_values' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 20
}
] | 1 |
python | import utils
class Model:
def __init__(self, file_path):
with open(file_path, 'r', encoding="utf8") as model_file:
self.model_tree = {}
for line in model_file:
chars, minus_log_p = utils.parse_model_file_line(line)
n_1_gram = ''.join(chars[:-1])
last_char = chars[-1]
if n_1_gram not in self... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 6
}
] | 1 |
python | from django.template import Template, Context
from django.utils.deprecation import MiddlewareMixin
from django.conf import settings
from django.db.models import Q
from django.urls import reverse, NoReverseMatch
from django.core.exceptions import ObjectDoesNotExist
from .signals import page_found, page_not_found, page_... | Review this code and list any quality issues. | [
{
"issue": "Function 'normalize_path' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 15
},
{
"issue": "Function 'get_page_by_path' has cyclomatic complexity 10 (threshold: 5). Consider breaking it into smaller functions.",
... | 3 |
python | import logging
from six import string_types
from traitlets import Bool
from traitlets.config.configurable import Configurable
from ipypublish.utils import handle_error, pathlib
try:
from shutil import which as exe_exists
except ImportError:
from distutils.spawn import find_executable as exe_exists # noqa: F... | Review this code and list any quality issues. | [
{
"issue": "Function '__call__' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 65
},
{
"issue": "Function 'postprocess' has cyclomatic complexity 13 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"l... | 6 |
python | import sublime
import sublime_plugin
import re
completions = []
def plugin_loaded():
init_settings()
def init_settings():
get_settings()
sublime.load_settings('img-placeholder.sublime-settings').add_on_change('get_settings', get_settings)
def get_settings():
settings = sublime.load_settings('img-pla... | Review this code and list any quality issues. | [
{
"issue": "Function 'is_trigger' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 54
}
] | 1 |
python | #####################################################################################
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# This source code is subject to terms and conditions of the Apache License, Version 2.0. A
# copy of the license can be found in the License.html file at the root of t... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_slice' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 30
},
{
"issue": "Function 'test_xrange' has cyclomatic complexity 12 (threshold: 5). Consider breaking it into smaller functions.",
"seve... | 11 |
python | import sys
import os
import shutil
import cv2
import open3d as o3d
import open3d.core as o3c
import numpy as np
from rendering.pytorch3d_renderer import PyTorch3DRenderer
from data import StandaloneFrameDataset
import data.presets as presets
import tsdf.default_voxel_grid
import data.camera
from settings import proce... | Review this code and list any quality issues. | [
{
"issue": "Function 'main' is 34 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 20
}
] | 1 |
python | # coding=utf-8
# *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
# *** 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, overload
from .. import... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has cyclomatic complexity 17 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 23
},
{
"issue": "Function '__init__' has 9 parameters. Consider using a parameter object to reduce arity.",
"severity": "critical",
... | 4 |
python | # -*- coding: utf-8 -*-
# Copyright © 2013-2014 Udo Spallek, Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the
# Software without restriction, including without limitation
#... | Review this code and list any quality issues. | [
{
"issue": "Function 'run' has cyclomatic complexity 23 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 116
},
{
"issue": "Function 'run' is 52 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "critical",
"l... | 2 |
python | """Module for summarizing cargo planning testing results.
Ed Polanco
ed.polanco@outlook.com
"""
import pandas as pd
from collections import OrderedDict
import datetime
import time
from aimacode.search import Problem, Node
from timeit import default_timer as timer
from run_search import PrintableProblem, PROBL... | Review this code and list any quality issues. | [
{
"issue": "Function 'search_data' is 33 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 83
}
] | 1 |
python | # Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
from typing import Any, List
import torch.nn as nn
from vissl.utils.misc import is_apex_available
_CONV_TYPES = (nn.Conv1d, n... | Review this code and list any quality issues. | [
{
"issue": "Function '_get_bn_optimizer_params' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 29
},
{
"issue": "Function '_assign_regularized_params' has cyclomatic complexity 10 (threshold: 5). Consider breaking it into s... | 4 |
python | # -*- coding: utf-8 -*-
# Copyright (c) 2020. Distributed under the terms of the MIT License.
from dataclasses import dataclass
from math import sqrt, pi
from typing import List
import numpy as np
from monty.json import MSONable
from tqdm import tqdm
from vise.util.mix_in import ToJsonFileMixIn
from scipy.constants i... | Review this code and list any quality issues. | [
{
"issue": "Function 'kramers_kronig_trans' has cyclomatic complexity 11 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 87
},
{
"issue": "Function 'kramers_kronig_trans' is 26 lines long. Functions over 25 lines are harder to test and maintain.",
... | 2 |
python | #!/usr/bin/env python3
# Copyright (c) 2017 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test ysw-cli"""
from test_framework.test_framework import YieldSakingWalletTestFramework
from test_framework... | Review this code and list any quality issues. | [
{
"issue": "Function 'run_test' is 32 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 16
}
] | 1 |
python | # PyTorch StudioGAN: https://github.com/POSTECH-CVLab/PyTorch-StudioGAN
# The MIT License (MIT)
# See license file or visit https://github.com/POSTECH-CVLab/PyTorch-StudioGAN for details
# src/main.py
import json
import os
import sys
import random
import warnings
from argparse import ArgumentParser
from utils.misc ... | Review this code and list any quality issues. | [
{
"issue": "Function 'main' has cyclomatic complexity 16 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 33
},
{
"issue": "Function 'main' is 75 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "critical",
"... | 2 |
python | import unittest
import mock
from stacker.context import Context
from stacker.exceptions import ImproperlyConfigured
from stacker.plan import (
Step,
Plan,
)
from stacker.status import (
COMPLETE,
SKIPPED,
SUBMITTED,
)
from stacker.stack import Stack
from .factories import generate_definition
cou... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_execute_plan_ensure_parallel_builds' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 124
},
{
"issue": "Function 'test_execute_plan_ensure_parallel_builds' is 35 lines long. Functions over 25 lines... | 2 |
python | import numpy as np
from scipy.ndimage import uniform_filter1d
from scipy.signal import detrend
def find_peaks_original(x, scale=None, debug=False):
"""Find peaks in quasi-periodic noisy signals using AMPD algorithm.
Automatic Multi-Scale Peak Detection originally proposed in
"An Efficient Algorithm for A... | Review this code and list any quality issues. | [
{
"issue": "Function 'find_peaks_adaptive' is 26 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 113
}
] | 1 |
python | #Monthly
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.mlab as ml
import datetime
from dateutil.relativedelta import relativedelta
import re
import numpy as np
from math import sin, cos, atan2, radians, sqrt
import scipy.interpolate
import gc
import pdb
import imp
imp.load_source('GenMe... | Review this code and list any quality issues. | [
{
"issue": "Function 'plot_rad_cs_winds' has 6 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 136
},
{
"issue": "Function 'date_bin_plot_winds' has 8 parameters. Consider using a parameter object to reduce arity.",
"severity": "critical",
"l... | 2 |
python | from dataclasses import fields
from warnings import warn
__all__ = ['dataslots', 'with_slots']
def with_slots(*args, **kwargs):
warn("Use dataslots decorator instead of with_slots", category=PendingDeprecationWarning, stacklevel=2)
return dataslots(*args, **kwargs)
def dataslots(_cls=None, *, add_dict=Fals... | Review this code and list any quality issues. | [
{
"issue": "Function 'dataslots.wrap' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 23
}
] | 1 |
python | # qubit number=4
# total number=33
import cirq
import qiskit
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit import BasicAer, execute, transpile
from pprint import pprint
from qiskit.test.mock import FakeVigo
from math import log2
import numpy as np
import networkx as nx
def bitwise_... | Review this code and list any quality issues. | [
{
"issue": "Function 'build_oracle' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 29
},
{
"issue": "Function 'make_circuit' is 34 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "mino... | 2 |
python | # -*- coding: utf-8 -*-
"""This module implements a number of popular two-dimensional complex valued residual blocks."""
# Authors: Qinggang Sun
#
# Reference:
# Allen Goodman, Allen Goodman, Claire McQuin, Hans Gaiser, et al. keras-resnet
# https://github.com/broadinstitute/keras-resnet
# pylint:disab... | Review this code and list any quality issues. | [
{
"issue": "Function 'basic_3d' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 21
},
{
"issue": "Function 'basic_3d' has 8 parameters. Consider using a parameter object to reduce arity.",
"severity": "critical",
... | 5 |
python | #!/usr/bin/env python3
# Copyright (c) 2018 The Bitcoin developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the resolution of forks via avalanche."""
import random
from test_framework.mininode import P2PInterface, m... | Review this code and list any quality issues. | [
{
"issue": "Function 'run_test' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 50
},
{
"issue": "Function 'run_test' is 61 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
... | 2 |
python | #!/usr/bin/env python
'''This script converts from any image type supported by
Python imaging library to the RLE-encoded format used by
NxWidgets.
'''
from PIL import Image
def get_palette(img, maxcolors = 255):
'''Returns a list of colors. If there are too many colors in the image,
the least used are removed.
... | Review this code and list any quality issues. | [
{
"issue": "Function 'encode_row' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 59
}
] | 1 |
python | # Copyright 2015 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 'check_params' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 76
},
{
"issue": "Function 'fit' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": ... | 4 |
python | from abc import ABCMeta
from uuid import UUID
import jsonschema
from dateutil.parser import parse as dateparse
from uptimer.events import SCHEMATA_PATH
from uptimer.events.cache import schema_cache
from uptimer.helpers import to_bool, to_none
class EventDefinitionError(ValueError):
pass
class EventMeta(ABCMet... | Review this code and list any quality issues. | [
{
"issue": "Function '__new__' is 34 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 20
},
{
"issue": "Function '__new__' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 20
},
{
... | 4 |
python | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Gcp methods module."""
import json
import logging
from hvac import exceptions, utils
from hvac.api.vault_api_base import VaultApiBase
from hvac.constants.gcp import ALLOWED_SECRETS_TYPES, SERVICE_ACCOUNT_KEY_ALGORITHMS, SERVICE_ACCOUNT_KEY_TYPES
DEFAULT_MOUNT_POINT = '... | Review this code and list any quality issues. | [
{
"issue": "Function 'configure' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 20
},
{
"issue": "Function 'create_or_update_roleset' is 30 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"li... | 5 |
python | '''
这段代码源于网上
原文请见 https://my.oschina.net/hechunc/blog/3020284
'''
import RPi.GPIO as GPIO
import time
# 这个类表示单个的SG90模块
class Rotation:
frequency=50 #脉冲频率(Hz)
delta_theta=0.2 #步进转动间隔(度)
min_delay=0.0006 #转动delta_theta的理论耗时(s)
max_delay=0.4 #从0转到180的耗时(s)
def __init__(self,channel,min_theta,max_thet... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 15
},
{
"issue": "Function '__init__' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line"... | 2 |
python | import os
import math
import argparse
from datetime import datetime
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from tqdm import tqdm
from PIL import Image
import data_loader
from mau_ml_util.train_logger import TrainLogger
#from mau_ml_util.metric import SegmentationMetric... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has cyclomatic complexity 11 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 59
},
{
"issue": "Function '__init__' is 31 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
... | 8 |
python | # Copyright 2021 the authors.
# This file is part of Hy, which is free software licensed under the Expat
# license. See the LICENSE.
import sys
import builtins
import importlib
import inspect
import pkgutil
import traceback
from ast import AST
from funcparserlib.parser import NoParseError
from hy._compat import PY3_8... | Review this code and list any quality issues. | [
{
"issue": "Function 'pattern_macro.pattern_macro.dec.pattern_macro.pattern_macro.dec.wrapper_maker.wrapper' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 40
},
{
"issue": "Function '_same_modules' has cyclomatic complexit... | 7 |
python | '''
code by TaeHwan Jung(@graykode)
Original Paper and repository here : https://github.com/openai/gpt-2
GPT2 Pytorch Model : https://github.com/huggingface/pytorch-pretrained-BERT
'''
import copy
import torch
import math
import torch.nn as nn
from torch.nn.parameter import Parameter
def gelu(x):
retu... | Review this code and list any quality issues. | [
{
"issue": "Function 'load_weight' has cyclomatic complexity 11 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 16
},
{
"issue": "Function 'load_weight' is 30 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major... | 6 |
python | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Graba video leido desde la arducam
# Se le debe indicar el archivo de video a grabar y
# la duración de la captura en segundos.
# SINTAXIS: python capturar_video.py VIDEO TIEMPO
# 1- Ruta del video
# 2- Tiempo de grabacion en segundos
from ctypes import *
import ct... | Review this code and list any quality issues. | [
{
"issue": "Function 'readThread' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 132
},
{
"issue": "Function 'readThread' is 35 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",... | 4 |
python | # coding: utf-8
"""
VPlex REST API
A definition for the next-gen VPlex API # noqa: E501
OpenAPI spec version: 0.1
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
import pprint
import re # noqa: F401
import six
class RuleSet(object):
"""NOTE: This class is auto gen... | Review this code and list any quality issues. | [
{
"issue": "Function 'to_dict' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 71
}
] | 1 |
python | import numpy as np
from math import sqrt
import matplotlib.pyplot as plt
import numba
import time
from scipy.integrate import odeint
# a sample differential equation dy/dx = (x-y)/2
# def dydx(x,y):
# return ((x-y)/2)
# # find the value of y for a given x using step size h
# # and an initial value y0 at x0
# ... | Review this code and list any quality issues. | [
{
"issue": "Function 'boxODE' is 50 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 59
},
{
"issue": "Function 'boxODE' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 59
}
] | 2 |
python | """Fill journal and character hidden/friends-only columns
Revision ID: e2bedd00b085
Revises: 1fbcfecd195e
Create Date: 2021-07-26 05:43:43.742595
"""
# revision identifiers, used by Alembic.
revision = 'e2bedd00b085'
down_revision = '1fbcfecd195e'
from alembic import op
import sqlalchemy as sa
from sqlalchemy impor... | Review this code and list any quality issues. | [
{
"issue": "Function 'upgrade' is 37 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 21
},
{
"issue": "Function 'downgrade' is 59 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 67
}... | 2 |
python | """Run Alleyoop utrrates tool on Slamdunk results."""
import os
from plumbum import TEE
from resolwe.process import (
Cmd,
DataField,
FileField,
IntegerField,
Process,
StringField,
)
class AlleyoopUtrRates(Process):
"""Run Alleyoop utrrates."""
slug = "alleyoop-utr-rates"
proces... | Review this code and list any quality issues. | [
{
"issue": "Function 'run' is 26 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 65
}
] | 1 |
python | from pony.orm import *
from datetime import datetime
from model.contact import Contact
from model.group import Group
from pymysql.converters import decoders
class ORMFixtue:
db = Database()
class ORMGroup(db.Entity):
_table_ = 'group_list'
id = PrimaryKey(int, column='group_id')
name... | 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": 36
}
] | 1 |
python | from cereal import car
from common.conversions import Conversions as CV
from opendbc.can.parser import CANParser
from opendbc.can.can_define import CANDefine
from selfdrive.car.interfaces import CarStateBase
from selfdrive.car.chrysler.values import DBC, STEER_THRESHOLD
class CarState(CarStateBase):
def __init__(se... | Review this code and list any quality issues. | [
{
"issue": "Function 'update' is 47 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 15
},
{
"issue": "Function 'get_can_parser' is 55 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 81... | 2 |
python | import unittest
import unittest.mock
import os
from py_compile import compile
import sys
import random
import time
import tempfile
from filecmp import cmp
def make_random_string(length=25, lower=0, upper=255):
return "".join(chr(random.randint(lower,upper)) for i in range(length))
def tempname():
(handle, nam... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_basic_logging' is 36 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 45
}
] | 1 |
python | # -*- coding: utf-8 -*-
"""
Created on Sun Dec 1 22:17:20 2019
@author: Wei
"""
#from dash_app import default_log as log
import pandas as pd
import numpy as np
#import pytz
from datetime import datetime, tzinfo,timedelta
from pm4py.statistics.traces.log import case_statistics
from pm4py.algo.filtering.log.attribute... | Review this code and list any quality issues. | [
{
"issue": "Function 'filtered_log_df' is 29 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 19
},
{
"issue": "Function 'sort_df' has cyclomatic complexity 10 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor... | 3 |
python | # io.py
# Contact: Jacob Schreiber
# jmschr@cs.washington.edu
'''
This script focuses on data input and output, and currently supports the
following files:
* FastA
'''
from seq import *
class FastA( object ):
'''
This is a FastA file. It can contain many DNA, RNA, or Protein
sequences in it. This can be... | Review this code and list any quality issues. | [
{
"issue": "Function 'from_file' has cyclomatic complexity 11 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 50
},
{
"issue": "Function 'from_file' is 28 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
... | 3 |
python | #!/usr/bin/python3
###############################################################################
#
# Copyright (c) 2015-2020, Intel Corporation
# Copyright (c) 2019-2020, University of Utah
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Li... | Review this code and list any quality issues. | [
{
"issue": "Function 'dump_exec_output' has 6 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 79
},
{
"issue": "Function 'execute_blame_phase' has cyclomatic complexity 24 (threshold: 5). Consider breaking it into smaller functions.",
"severity":... | 8 |
python | class Solution:
def waterOverflow(self, K, R, C):
if R <= 0 or C <= 0 or C > R :
return 0
table = [[K]]
i = 0
while True :
table.append([0]*(i+2))
flag = True
for j in range(i+1) :
if table[i][j] > 1 :
... | Review this code and list any quality issues. | [
{
"issue": "Function 'waterOverflow' has cyclomatic complexity 10 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 2
}
] | 1 |
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
__a... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has cyclomatic complexity 12 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 15
},
{
"issue": "Function '__init__' is 43 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "critical... | 3 |
python | # --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_resource_lock_commands' is 27 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 149
},
{
"issue": "Function 'test_lock_commands_with_ids' is 35 lines long. Functions over 25 lines are harder to test and maintain.",
... | 3 |
python | from molsysmt._private.exceptions import *
from molsysmt._private.digestion import *
from .is_openmm_Topology import is_openmm_Topology
def to_openmm_System(item, atom_indices='all', forcefield=None, parameters=None, check=True):
if check:
try:
is_openmm_Topology(item)
except:
... | Review this code and list any quality issues. | [
{
"issue": "Function 'to_openmm_System' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 5
}
] | 1 |
python | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | Review this code and list any quality issues. | [
{
"issue": "Function '_construct_affine_bandlimit_filter' has 7 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 55
},
{
"issue": "Function 'render' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severi... | 8 |
python | from unittest import TestCase
from mock import Mock, call
from cloudshell.cp.aws.domain.services.ec2.vpc import VPCService
from cloudshell.cp.aws.domain.services.waiters.vpc_peering import VpcPeeringConnectionWaiter
class TestVPCService(TestCase):
def setUp(self):
self.tag_service = Mock()
self.... | Review this code and list any quality issues. | [
{
"issue": "Function 'setUp' is 30 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 10
}
] | 1 |
python | from django.apps import apps
from django.core.urlresolvers import reverse
from django.http import Http404
from django.shortcuts import get_object_or_404, redirect, render
from django.utils.text import capfirst
from django.utils.translation import ugettext as _
from wagtail.utils.pagination import paginate
from wagtail... | Review this code and list any quality issues. | [
{
"issue": "Function 'list' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 66
},
{
"issue": "Function 'list' is 39 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": ... | 4 |
python | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_query_profile_thrift_timestamps' is 28 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 231
}
] | 1 |
python | # coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes ... | 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": 42
}
] | 1 |
python |
# COUNT CONTAINED PERMUTATIONS
# O(M * U + N) time and O(U) space, where M -> length of big string,
# U -> number of unique characters in small string, N -> length
# of small string.
# U is actually a constant since it can't be greater than 26. and
# M > N, so M will dissolve N
# So, modified complexities:
# O(M) ti... | Review this code and list any quality issues. | [
{
"issue": "Function 'countContainedPermutations' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 11
}
] | 1 |
python | """
Copyright (c) 2021 TU Darmstadt
Author: Nikita Araslanov <nikita.araslanov@tu-darmstadt.de>
License: Apache License 2.0
"""
import os
import torch
from PIL import Image
import numpy as np
import torchvision.transforms as tf
from .dataloader_base import DLBase
class DataSeg(DLBase):
def __init__(self, cfg... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' is 40 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 20
},
{
"issue": "Function '__init__' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 20
},
{
... | 4 |
python | import math
import warnings
from itertools import combinations
from typing import TYPE_CHECKING
from typing import Optional
from typing import Sequence
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
import statsmodels.api as sm
from matplotlib.ticker import MaxNLocator
from statsmodels.graphi... | Review this code and list any quality issues. | [
{
"issue": "Function 'cross_corr_plot' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 22
},
{
"issue": "Function 'cross_corr_plot' is 30 lines long. Functions over 25 lines are harder to test and maintain.",
"severity":... | 4 |
python | #!/usr/bin/env python
"""Cluster SNVs based on SNV freqs confidence interval
"""
__author__ = "Andreas Wilm, Niranjan Nagarajan"
__email__ = "wilma@gis.a-star.edu.sg"
__copyright__ = "2013,2014 Genome Institute of Singapore"
__license__ = "The MIT License"
# --- standard library imports
#
import sys
import logging... | Review this code and list any quality issues. | [
{
"issue": "Function 'main' has cyclomatic complexity 33 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 124
},
{
"issue": "Function 'main' is 92 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "critical",
... | 2 |
python | """
.. module:: utils
:synopsis: Miscellaneous helper constructs
.. moduleauthor:: Steven Silvester <steven.silvester@ieee.org>
"""
import os
import inspect
import dis
import tempfile
import sys
from .compat import PY2
def _remove_temp_files(dirname):
"""
Remove the created mat files in ... | Review this code and list any quality issues. | [
{
"issue": "Function 'get_nout' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 30
},
{
"issue": "Function '__getitem__' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severit... | 2 |
python | import tensorflow as tf
from keras.activations import relu
from keras.initializers import VarianceScaling
from keras.layers import Dense, Conv2D, Flatten
from keras.losses import logcosh
class DDQN:
""" Implements a Dueling Dual Deep Q-Network based on the frames of the Retro Environment """
def __init__(sel... | 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": 11
},
{
"issue": "Function '__init__' has 6 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 11
},
{
... | 3 |
python | import torch
import torch.nn as nn
import torch.nn.functional as F
def _create_activation(activation_type):
if activation_type == 'relu':
return torch.relu
elif activation_type == 'swish':
return lambda x: x * torch.sigmoid(x)
raise ValueError('invalid activation_type.')
def create_encod... | Review this code and list any quality issues. | [
{
"issue": "Function 'create_encoder' is 33 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 14
},
{
"issue": "Function 'create_encoder' has 6 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": ... | 8 |
python | # coding: UTF-8
import argparse
import logging
import random
import torch
import copy
import numpy as np
from dataset import CDTB
from collections import Counter
from itertools import chain
from structure.vocab import Vocab, Label
from structure.nodes import node_type_filter, EDU, Relation, Sentence, TEXT
from treebuil... | Review this code and list any quality issues. | [
{
"issue": "Function 'gen_decoder_data' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 41
},
{
"issue": "Function 'gen_decoder_data' is 27 lines long. Functions over 25 lines are harder to test and maintain.",
"severity... | 8 |
python | """
Generic GeoRSS events service.
Retrieves current events (typically incidents or alerts) in GeoRSS format, and
shows information on events filtered by distance to the HA instance's location
and grouped by category.
For more details about this platform, please refer to the documentation at
https://home-assistant.io... | 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": 87
}
] | 1 |
python | #!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
Date: 2021/9/12 18:29
Desc: 巨潮资讯-数据中心-评级预测-投资评级
http://webapi.cninfo.com.cn/#/thematicStatistics?name=%E6%8A%95%E8%B5%84%E8%AF%84%E7%BA%A7
"""
import time
from py_mini_racer import py_mini_racer
import requests
import pandas as pd
js_str = """
function mcode(input) ... | Review this code and list any quality issues. | [
{
"issue": "Function 'stock_rank_forecast_cninfo' is 54 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 44
}
] | 1 |
python | import copy
def filterRemaining(remaining, environment):
returned = copy.copy(remaining)
for i in range(len(returned)-1, -1, -1):
r = returned[i]
if any(not(r[e]==environment[e]) for e in environment if e in r):
del returned[i]
else:
runs = copy.copy(r['runs'])
... | Review this code and list any quality issues. | [
{
"issue": "Function 'filterRemaining' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 4
}
] | 1 |
python | import functools
import queue
import random
import time
from concurrent.futures import ThreadPoolExecutor
from itertools import repeat
from log import logger
shut_down_pool_queue = queue.Queue()
# sys_thread_pool = ThreadPoolExecutor(max_workers=2)
def shutdown_listener():
for _ in repeat(None):
t_poo... | Review this code and list any quality issues. | [
{
"issue": "Function 'run' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 85
}
] | 1 |
python | import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision import transforms, datasets
import logging
import argparse
import sys
import asyncio
import numpy as np
import syft as sy
from syft import workers
from syft.frameworks.torch.federated import utils
logger = logging.getLogger(__name__)... | Review this code and list any quality issues. | [
{
"issue": "Function 'define_and_get_arguments' is 29 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 47
},
{
"issue": "Function 'fit_model_on_worker' is 28 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": ... | 7 |
python | from qtpy.QtCore import QPointF
from nezzle.utils import TriggerDict
class BaseArrow(object):
ITEM_TYPE = 'BASE_HEAD'
DEFAULT_OFFSET = 4
def __init__(self, width, height, offset):
self._attr = TriggerDict()
self._attr['ITEM_TYPE'] = self.ITEM_TYPE
self._offset = offset
... | 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": 111
},
{
"issue": "Function '__init__' has 6 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 156
}
] | 2 |
python | # Copyright 2012 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 requ... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_version_configurations' is 51 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 28
},
{
"issue": "Function 'test_v2_api_configuration' is 43 lines long. Functions over 25 lines are harder to test and maintain.",
"se... | 3 |
python | #!/usr/bin/env python3.6
from passlock import User, Credentials
def function():
print(" ____ _____ _ ")
print(" | _ \ / ____|| | ")
print(" | |_) ) ____ ___ ___ /... | Review this code and list any quality issues. | [
{
"issue": "Function 'passlocker' has cyclomatic complexity 21 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 88
},
{
"issue": "Function 'passlocker' is 102 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "cri... | 2 |
python | from panda3d.core import *
from toontown.toontowngui import TTDialog
from toontown.toonbase import TTLocalizer
from direct.gui import DirectLabel
from toontown.quest import Quests
class NPCForceAcknowledge:
def __init__(self, doneEvent):
self.doneEvent = doneEvent
self.dialog = None
return... | Review this code and list any quality issues. | [
{
"issue": "Function 'enter' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 14
},
{
"issue": "Function 'enter' is 30 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line"... | 2 |
python | from xml.dom import Node
from htmltreediff.util import (
get_child,
get_location,
remove_node,
insert_or_append,
)
class EditScriptRunner(object):
def __init__(self, dom, edit_script):
self.dom = dom
self.edit_script = edit_script
self.del_nodes = []
self.ins_nodes... | Review this code and list any quality issues. | [
{
"issue": "Function 'action_insert' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 27
},
{
"issue": "Function 'action_insert' has 7 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
... | 2 |
python | # -*- coding: utf-8 -*-
'''
Episode 7-3
'''
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '../..'))
sys.path.append('storybuilder')
from storybuilder.builder.world import World
# DEFINE
TITLE = "英雄の帰還"
# NOTE: outlines
ABSTRACT = """
変身して$sherlockたちを追い詰める$jake。しかし$sherlockの機転で工場に穴を開け、... | Review this code and list any quality issues. | [
{
"issue": "Function 'main' is 66 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 30
}
] | 1 |
python | import pandas as pd
import argparse
import logging
import sys
import json
def get_best_logger(log_file, verbose):
# Setup logger - (Python logger breaks PEP8 by default)
logger = logging.getLogger(__name__)
if verbose:
logger.setLevel('DEBUG')
# file_handler logs to file, stream_handler to con... | Review this code and list any quality issues. | [
{
"issue": "Function 'compare_addresses' has cyclomatic complexity 10 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 28
},
{
"issue": "Function 'compare_addresses' is 39 lines long. Functions over 25 lines are harder to test and maintain.",
"sever... | 3 |
python | import os
import traceback
import base64
import datetime
import logging
from xml.etree.ElementTree import XML
from signxml import xmldsig
__all__ = ['AuthenticationError', 'parse_saml']
def decode_response(resp):
return base64.b64decode(resp.encode('utf8'))
# Getters
def get_xmldoc(xmlstring):
return XM... | Review this code and list any quality issues. | [
{
"issue": "Function 'parse_saml' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 74
},
{
"issue": "Function 'parse_saml' is 51 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
... | 2 |
python | """Whale Alert view"""
__docformat__ = "numpy"
import logging
import os
from openbb_terminal.cryptocurrency.onchain import whale_alert_model
from openbb_terminal.decorators import check_api_key
from openbb_terminal.decorators import log_start_end
from openbb_terminal.helper_funcs import (
export_data,
lambda_... | Review this code and list any quality issues. | [
{
"issue": "Function 'display_whales_transactions' is 32 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 22
},
{
"issue": "Function 'display_whales_transactions' has 6 parameters. Consider using a parameter object to reduce arity.",
"severi... | 2 |
python | import logging
from cleo.config import ApplicationConfig as BaseApplicationConfig
from clikit.api.event import PRE_HANDLE
from clikit.api.event import PreHandleEvent
from clikit.api.formatter import Style
from clikit.api.io import Input
from clikit.api.io import InputStream
from clikit.api.io import Output
from clikit... | Review this code and list any quality issues. | [
{
"issue": "Function 'register_command_loggers' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 40
},
{
"issue": "Function 'create_io' has cyclomatic complexity 17 (threshold: 5). Consider breaking it into smaller functions.... | 4 |
python | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import numpy as np # type: ignore
import onnx
from ..base import Base
from . import expect
class BatchNormalization(Base):
@staticmethod
def export(): # typ... | Review this code and list any quality issues. | [
{
"issue": "Function 'export._batchnorm_test_mode' has 6 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 17
},
{
"issue": "Function 'export' is 30 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"li... | 2 |
python | '''
Given the root of a binary tree, return the level order traversal of its nodes' values.
(i.e., from left to right, level by level).
Example 1:
Input: root = [3,9,20,null,null,15,7]
Output: [[3],[9,20],[15,7]]
Example 2:
Input: root = [1]
Output: [[1]]
Example 3:
Input: root = []
Output: []
'''
# Definition... | Review this code and list any quality issues. | [
{
"issue": "Function 'levelOrder' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 37
}
] | 1 |
python | """
This module is used to predict the Air Quality Index model for 2019 for all counties.
"""
import pickle
import warnings
import pandas as pd
import numpy as np
from keras.models import load_model
import helpers
warnings.filterwarnings("ignore")
def main():
data2019_raw = pd.read_csv("""air_pollution_death_r... | Review this code and list any quality issues. | [
{
"issue": "Function 'main' is 41 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 15
}
] | 1 |
python | # -*- coding: utf-8 -*-
class State :
"""
Classe définissant un état caractérisée par :
- un identifiant
- un booleen pour savoir si c'est un état initial
- un booleen pour savoir si c'est un état final
- un label utilisé pour les constructions
ou il faut memorise... | 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": 13
}
] | 1 |
python | from ....control import core
from ....control.instruments.berkeleynucleonics765 import stop
from ..switching import preset_run_function
import pandas as pd
import numpy as np
import os
import warnings
import time
__all__ = ("FE",)
class FE(core.experiment):
"""Experiment class for running pulsed Ferroelectric ... | 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": 29
},
{
"issue": "Function 'checks' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": ... | 3 |
python | __all__ = ['kd_tree']
from math import sqrt
from heapq import heappush,heappop
class kd_tree:
class node:
def point_distance(self,point):
return sqrt(sum([ (a - b)**2 for (a,b) in zip(point,self.point)]))
def separator_distance(self,point):
return point[self.axis] - self.p... | Review this code and list any quality issues. | [
{
"issue": "Function '__nearest_n' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 168
},
{
"issue": "Function '__nearest_n' has 6 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
... | 2 |
python | import sys
def problem():
"""
Minimal Tree: Given a sorted (increasing order) array with unique integer elements, write an algorithm to create a binary search tree with minimal height.
"""
pass
class BST:
def __init__(self):
self.count = 0
self.root = None
... | Review this code and list any quality issues. | [
{
"issue": "Function '__is_BST' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 67
}
] | 1 |
python | #!/usr/bin/env python
import python_bitbankcc
from math import floor
from datetime import datetime
import pathlib
import csv
from settings import BITBANK_API_KEY, BITBANK_API_SECRET
class BitBankPubAPI:
def __init__(self):
self.pub = python_bitbankcc.public()
def get_ticker(self, pair):
try:... | Review this code and list any quality issues. | [
{
"issue": "Function 'main' is 26 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 47
}
] | 1 |
python | import os
from os.path import isfile, join
from PIL import Image
import pandas as pd
import torch
from torch.utils.data.dataset import Dataset
from torchvision import transforms
import numpy as np
import matplotlib.pyplot as plt
import shutil
from sklearn.model_selection import KFold
from sklearn.model_selection import... | Review this code and list any quality issues. | [
{
"issue": "Function 'get_stratified_by_area_folds' is 33 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 18
},
{
"issue": "Function 'get_stratified_by_area_folds' has 5 parameters. Consider using a parameter object to reduce arity.",
"seve... | 8 |
python | from . import PythonExpressions
class CodeBlock:
def get_code(self, scope):
return NotImplemented
class CBAssign(CodeBlock):
def __init__(self, var, value):
self._var = var
self._value = value
def get_code(self, scope):
return f"SCOPE.set_var(\"{s... | 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": 72
},
{
"issue": "Function 'get_code' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line"... | 2 |
python | """
The data-file handling functions
"""
#-----------------------------------------------------------------------------
# Copyright (c) 2013, yt Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#----------... | Review this code and list any quality issues. | [
{
"issue": "Function '_read_chunk_data' has cyclomatic complexity 12 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 40
},
{
"issue": "Function '_read_chunk_data' is 43 lines long. Functions over 25 lines are harder to test and maintain.",
"severit... | 5 |
python | import os
import os.path
import re
import sqlite3dbm
from threading import RLock
from hippybot.hipchat import HipChatApi
from hippybot.decorators import botcmd, contentcmd
CONFIG_DIR = os.path.expanduser("~/.techbot")
DB = os.path.expanduser("~/.techbot/score.db")
class Plugin(object):
"""Plugin to handle knewton re... | Review this code and list any quality issues. | [
{
"issue": "Function 'change_score' has cyclomatic complexity 10 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 34
}
] | 1 |
python | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Logchecker tool for scanning log files against YETI Threat Intelligence Repository.
By LIFARS
This code is licensed under MIT license (see LICENSE for details)
"""
__version__ = "0.8"
__author__ = "LIFARS LLC"
__copyright__ = "Copyright (c) 2020,2021 LIFARS LLC"
__cr... | Review this code and list any quality issues. | [
{
"issue": "Function 'main' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 41
},
{
"issue": "Function 'main' is 106 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line":... | 6 |
python | from mock import patch, MagicMock, call
from allegation.factories import (
DownloadFactory, OfficerAllegationFactory, AllegationFactory, ComplainingWitnessFactory, OfficerFactory)
from allegation.services.download_allegations import AllegationsDownload
from api.models import Setting
from common.tests.core import S... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_officer_sheet' is 28 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 85
}
] | 1 |
python | # -*- coding: utf-8 -*-
#
# GRR documentation build configuration file, created by
# sphinx-quickstart on Wed Nov 22 17:54:03 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All c... | Review this code and list any quality issues. | [
{
"issue": "Function 'find_replace' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 178
}
] | 1 |
python | from itertools import combinations
import pandas as pd
from utils.utils import *
def load_etf():
etf_data = pd.read_csv(
"data/etf_data.csv", encoding="euc_kr", parse_dates=["tdate"]
)
etf_ohlcv = etf_data.set_index(["tdate", "etf_code", "data_name"])[
"value"
].unstack()
etf_clos... | Review this code and list any quality issues. | [
{
"issue": "Function 'features_from_wics' is 48 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 64
},
{
"issue": "Function 'combination_set' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"li... | 2 |
python | # -*- encoding: UTF-8 -*-
import string
from neko.Common import Threat
from neko.Common.CLSID import CLSID_NULL, LOW_RISK_LEVEL_OBJECTS, HIGH_RISK_LEVEL_OBJECTS
from neko.Common.DataStructures.OLE1 import LengthPrefixedByteArray
from neko.Common.DataStructures.OLE2 import OLEStream, SOAPMoniker, CompositeMoniker, Fi... | Review this code and list any quality issues. | [
{
"issue": "Function 'CheckDirectoryEntryNames' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 33
},
{
"issue": "Function 'CheckDirectoryEntryNames' is 30 lines long. Functions over 25 lines are harder to test and maintain.... | 7 |
python | # From https://stackoverflow.com/a/34325723
_prev_str_length = None
# Print iterations progress
def print_progress_bar(iteration, total, prefix='', suffix='', decimals=1, length=18, fill='█'):
"""
Call in a loop to create terminal progress bar
@params:
iteration - Required : current iteration (Int)
total ... | Review this code and list any quality issues. | [
{
"issue": "Function 'print_progress_bar' has 7 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 6
}
] | 1 |
python | from __future__ import absolute_import
import time
import os
import unittest
import tempfile
import shutil
from io import StringIO
from . import punc
from .punc import Punctuator, download_model
class Tests(unittest.TestCase):
samples = [
(
'mary had a little lamb its fleece was white as sn... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_punctuate' is 39 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 39
},
{
"issue": "Function 'test_punctuate_stream' is 41 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",... | 2 |
python | """
SleekXMPP: The Sleek XMPP Library
Copyright (C) 2011 Nathanael C. Fritz
This file is part of SleekXMPP.
See the file LICENSE for copying permission.
"""
import ssl
import logging
from sleekxmpp.util import sasl
from sleekxmpp.util.stringprep_profiles import StringPrepError
from sleekxmpp.stanza ... | Review this code and list any quality issues. | [
{
"issue": "Function 'plugin_init' is 36 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 45
},
{
"issue": "Function '_default_credentials' has cyclomatic complexity 11 (threshold: 5). Consider breaking it into smaller functions.",
"severity... | 6 |
python | def findDecision(obj): #obj[0]: Driving_to, obj[1]: Passanger, obj[2]: Weather, obj[3]: Temperature, obj[4]: Time, obj[5]: Coupon, obj[6]: Coupon_validity, obj[7]: Gender, obj[8]: Age, obj[9]: Maritalstatus, obj[10]: Children, obj[11]: Education, obj[12]: Occupation, obj[13]: Income, obj[14]: Bar, obj[15]: Coffeehouse,... | Review this code and list any quality issues. | [
{
"issue": "Function 'findDecision' has cyclomatic complexity 75 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 1
},
{
"issue": "Function 'findDecision' is 150 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "... | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.