language stringclasses 1
value | code stringlengths 407 33.3k | instruction stringclasses 1
value | flaws listlengths 1 17 | flaw_count int64 1 17 |
|---|---|---|---|---|
python | """Support for monitoring the rtorrent BitTorrent client API."""
import logging
import xmlrpc.client
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (
CONF_URL, CONF_NAME,
CONF_MONITORED_VARIABLES, STATE_IDLE)
from homeassistant.helpers.enti... | Review this code and list any quality issues. | [
{
"issue": "Function 'update' has cyclomatic complexity 13 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 93
},
{
"issue": "Function 'update' is 30 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"li... | 2 |
python | import glob
import sys
##### creatin dict that will have all control positions
def con_pos(con_MH):
con_dict = {}
f = open(con_MH, 'r')
for line in f:
s = line.split()
chr = s[0]
pos = s[1]
ref = int(s[7]) #ref depth
alt = int(s[9]) #alt depth
vaf = float(alt)/(ref+alt)
alt_type = s[8] #alt base
... | Review this code and list any quality issues. | [
{
"issue": "Function 'write_final' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 58
},
{
"issue": "Function 'main' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line":... | 2 |
python |
# importing all modules
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.colors as colors
from matplotlib import cm
import matplotlib.tri as tri
from matplotlib.colors import LogNorm
import matplotlib.patches as mpatches
from matplotlib.ticker import LogFormatter
from co... | Review this code and list any quality issues. | [
{
"issue": "Function 'f2' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 48
},
{
"issue": "Function 'f2' is 55 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 48
... | 3 |
python | from pextant.lib.geoshapely import GeoPolygon, LONG_LAT
import numpy as np
import csv
class SEXTANTSolver(object):
def __init__(self, environmental_model, cost_function, viz):
self.env_model = environmental_model
self.cost_function = cost_function
self.viz = viz
self.searches = []
... | Review this code and list any quality issues. | [
{
"issue": "Function 'addresult' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 30
},
{
"issue": "Function '__init__' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 77
}
] | 2 |
python | import random
import warnings
class Client:
def __init__(self, client_id, group=None, train_data={'x' : [],'y' : []}, eval_data={'x' : [],'y' : []}, model=None):
self._model = model
self.id = client_id
self.group = group
self.train_data = train_data
self.eva... | 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": 7
}
] | 1 |
python | import argparse
from datetime import datetime
from tensorflow.contrib.keras.python.keras.initializers import TruncatedNormal
from docqa import trainer
from docqa.data_processing.qa_training_data import ContextLenKey
from docqa.dataset import ClusteredBatcher
from docqa.encoder import DocumentAndQuestionEncoder, Singl... | Review this code and list any quality issues. | [
{
"issue": "Function 'main' is 73 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 25
}
] | 1 |
python | from Tkinter import *
from PIL import ImageTk, Image
import tkMessageBox
import sys
import os
def getNoImagesInDirectory(dir):
return len(getImagesInDirectory(dir))
def getImagesInDirectory(dir):
files = os.listdir(dir)
images = []
for file in files:
if file.lower().endswith((".jpg", ".png",... | 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": 65
}
] | 1 |
python | import os
import torch
from weaver.utils.logger import _logger
from weaver.utils.import_tools import import_module
ParticleTransformer = import_module(
os.path.join(os.path.dirname(__file__), 'ParticleTransformer.py'), 'ParT').ParticleTransformer
class ParticleTransformerWrapper(torch.nn.Module):
def __init_... | Review this code and list any quality issues. | [
{
"issue": "Function 'forward' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 19
},
{
"issue": "Function 'get_model' is 27 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 23
}
] | 2 |
python | """
This is a framework for terminal interfaces built on top of urwid.Frame.
It must NOT contain any application specific code.
"""
import logging
import threading
from concurrent.futures.thread import ThreadPoolExecutor
import urwid
from sen.exceptions import NotifyError
from sen.tui.commands.base import (
Fron... | Review this code and list any quality issues. | [
{
"issue": "Function 'build_statusbar' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 177
},
{
"issue": "Function 'notify_message' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "mino... | 5 |
python | __copyright__ = "Copyright (c) 2020 Jina AI Limited. All rights reserved."
__license__ = "Apache-2.0"
from typing import Iterable
from .. import QuerySetReader, BaseRecursiveDriver
if False:
from ...proto import jina_pb2
class SliceQL(QuerySetReader, BaseRecursiveDriver):
"""Restrict the size of the ``docs... | 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 | import copy
import numpy as np
import warnings
from .regularizer import Regularizer
class Oracle():
"""
Base class for all objectives. Can provide objective values,
gradients and its Hessians as functions that take parameters as input.
Takes as input the values of l1 and l2 regularization.
... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' has cyclomatic complexity 10 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 14
},
{
"issue": "Function '__init__' has 6 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line... | 3 |
python | # -*- coding: utf-8 -*-
# Copyright © 2017 Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can
# be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import sys
from code import InteractiveInterpreter
def main():
"""
Print l... | Review this code and list any quality issues. | [
{
"issue": "Function 'main' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 10
}
] | 1 |
python | import re
from typing import Tuple
from duty.utils import att_parse, format_response
from duty.objects import MySignalEvent, dp
def delete_template(name: str, templates: list) -> Tuple[list, bool]:
for template in templates:
if template['name'].lower() == name:
templates.remove(template)
... | Review this code and list any quality issues. | [
{
"issue": "Function 'get_template_list' has cyclomatic complexity 12 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 16
},
{
"issue": "Function 'get_template_list' is 30 lines long. Functions over 25 lines are harder to test and maintain.",
"sever... | 6 |
python | import sys
from threading import Thread
from connection import TcpConnection
from proto.tcp_packet_pb2 import TcpPacket
class Chat():
def __init__(self):
self.connection = TcpConnection()
self.packet = TcpPacket()
def createLobby(self, maxPlayers, *args):
payload = self.packet.CreateLobbyPacket()
... | Review this code and list any quality issues. | [
{
"issue": "Function '_parsePacket' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 95
}
] | 1 |
python | mask4bits = ((1 << 4) -1)
import numpy as np
mask8bits = ((1 << 8) -1)
mask16bits = ((1 << 16) -1)
mask64bits = ((1 << 64) -1)
class SNAPPacket(object):
"""
ATA SNAP Firmware Manual, Release 2.0.0
---------------------------------------
Section 2.3.2 "Output Data Formats: Voltage Packets", pg 5
ht... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' is 28 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "critical",
"line": 42
},
{
"issue": "Function '__init__' has 10 parameters. Consider using a parameter object to reduce arity.",
"severity": "critical",
"line": 42
... | 6 |
python | #!/usr/bin/env python
# --------------------------------------------------------
# FCN
# Copyright (c) 2016 RSE at UW
# Licensed under The MIT License [see LICENSE for details]
# Written by Yu Xiang
# --------------------------------------------------------
"""Test a FCN on an image database."""
import _init_paths
f... | 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": 23
}
] | 1 |
python | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import simplejson as json
from alipay.aop.api.constant.ParamConstants import *
class AlipayFundAuthOperationCancelModel(object):
def __init__(self):
self._auth_no = None
self._operation_id = None
self._out_order_no = None
self._out_re... | Review this code and list any quality issues. | [
{
"issue": "Function 'to_alipay_dict' has cyclomatic complexity 11 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 54
},
{
"issue": "Function 'to_alipay_dict' is 28 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": ... | 3 |
python | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'confirm.ui'
#
# Created by: PyQt5 UI code generator 5.9.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectN... | Review this code and list any quality issues. | [
{
"issue": "Function 'setupUi' is 38 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 12
}
] | 1 |
python | import re
import os.path as path
from importlib import import_module
from django.template.context import BaseContext
def dict_from_context(context):
"""
Converts context to native python dict.
"""
if isinstance(context, BaseContext):
new_dict = {}
for i in reversed(list(context)):
... | Review this code and list any quality issues. | [
{
"issue": "Function 'patch_django_for_autoescape' has cyclomatic complexity 12 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 41
}
] | 1 |
python | #!/usr/bin/env python
"""
Code to load an expert policy and generate roll-out data for behavioral cloning.
Example usage:
python run_expert.py experts/Humanoid-v1.pkl Humanoid-v1 --render \
--num_rollouts 20
Author of this script and included expert policies: Jonathan Ho (hoj@openai.com)
"""
import o... | Review this code and list any quality issues. | [
{
"issue": "Function 'main' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 20
},
{
"issue": "Function 'main' is 45 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": ... | 2 |
python | from collections.abc import Sequence
import mmcv
import numpy as np
import torch
from mmcv.parallel import DataContainer as DC
from ..builder import PIPELINES
def to_tensor(data):
"""Convert objects of various python types to :obj:`torch.Tensor`.
Supported types are: :class:`numpy.ndarray`, :class:`torch.T... | Review this code and list any quality issues. | [
{
"issue": "Function 'to_tensor' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 11
},
{
"issue": "Function '__call__' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity"... | 2 |
python | from otree.api import Currency as c, currency_range, SubmissionMustFail
from . import pages
from ._builtin import Bot
from .models import Constants
class PlayerBot(Bot):
cases = [
{'offer': 1, 'return_1': 1, 'return_2': 1,
'return_2_A': 1, 'return_2_B': 1,
'p1_payoff': 5, 'p2_payoff': 5... | Review this code and list any quality issues. | [
{
"issue": "Function 'play_round' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 14
}
] | 1 |
python | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import random
import argparse
import cv2 as cv
import numpy as np
from tqdm import tqdm
from create_7segment_image import create_7segment_image
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument("--width", help='ima... | Review this code and list any quality issues. | [
{
"issue": "Function 'main' is 75 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 46
}
] | 1 |
python | # -*- coding: utf-8 -*-
# author: @RShirohara
# TODO: #8
from time import sleep
from .detect import DetectArea
from .googleapis import DetectText, GetTTS
from .send import PlayMP3
from .util import VideoStream, QueueConnector
class Tegaki:
"""HandWriting Detection core class.
Attributes:
capture (... | 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 | _backendsNames = ("bouncyCastle", "pgpy")
from pathlib import Path
from os.path import expanduser
from enum import IntFlag
from abc import ABC, abstractmethod
keyringPath = Path(expanduser("~/.gnupg/pubring.kbx"))
class SecurityIssues(IntFlag):
OK = 0
wrongSig = (1 << 0)
expired = (1 << 1)
disabled = (1 << 2)
r... | Review this code and list any quality issues. | [
{
"issue": "Function 'verifyBlob' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 28
}
] | 1 |
python | from os import write as os_write, close as os_close, O_WRONLY as os_O_WRONLY, O_CREAT as os_O_CREAT, open as os_open, remove as os_remove
from twisted.web import resource, http
class UploadResource(resource.Resource):
FILENAME = "/tmp/autotimer_backup.tar"
def __init__(self, session):
self.session = session
re... | Review this code and list any quality issues. | [
{
"issue": "Function 'render_POST' is 33 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 12
}
] | 1 |
python | #!/bin/bash
import os
import sys
import random
import cv2
import numpy as np
import xgboost as xgb
from sklearn import preprocessing
from sklearn.decomposition import PCA, NMF
from sklearn.model_selection import train_test_split, GridSearchCV
from sklearn.svm import SVC
from sklearn.ensemble import RandomForestClassif... | Review this code and list any quality issues. | [
{
"issue": "Function 'sample_negative' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 21
},
{
"issue": "Function 'sample_negative' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "mino... | 5 |
python | import gym
import numpy
from PIL import Image
from nes_py.wrappers import JoypadSpace
from gym_super_mario_bros.actions import COMPLEX_MOVEMENT
class NopOpsEnv(gym.Wrapper):
def __init__(self, env=None, max_count=30):
super(NopOpsEnv, self).__init__(env)
self.max_count = max_count
def reset(s... | 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": 42
},
{
"issue": "Function 'WrapperSuperMario' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 100
},
... | 3 |
python | """
Copyright 2016 Deepgram
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, software
distri... | Review this code and list any quality issues. | [
{
"issue": "Function 'readme' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 53
}
] | 1 |
python | '''
Author: hanyu
Date: 2020-11-06 13:04:12
LastEditTime: 2021-01-09 09:07:08
LastEditors: hanyu
Description: environment
FilePath: /test_ppo/examples/PPO_super_mario_bros/env.py
'''
import logging
import numpy as np
from collections import namedtuple
# todo, to common
def padding(input, seqlen, dtype):
input = ... | Review this code and list any quality issues. | [
{
"issue": "Function '_warp_env.__init__' is 28 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "critical",
"line": 44
},
{
"issue": "Function '_warp_env.__init__' has 8 parameters. Consider using a parameter object to reduce arity.",
"severity": "critical"... | 8 |
python | #
# Loop transformation submodule.that implements a combination of various loop transformations.
#
import sys
import orio.module.loop.submodule.submodule, transformation
import orio.module.loop.submodule.tile.tile
import orio.module.loop.submodule.permut.permut
import orio.module.loop.submodule.regtile.regtile
import ... | 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": 23
},
{
"issue": "Function '__readTransfArgs' has cyclomatic complexity 14 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
... | 8 |
python | import copy
import os
import torch
import torch.utils.data
import torchvision
from pycocotools import mask as coco_mask
from pycocotools.coco import COCO
import dataProcessing.transforms as T
import logging
class FilterAndRemapCocoCategories(object):
def __init__(self, categories, remap=True):
self.catego... | Review this code and list any quality issues. | [
{
"issue": "Function '__call__' has cyclomatic complexity 14 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 79
},
{
"issue": "Function '__call__' is 41 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
... | 6 |
python | import tensorflow as tf
# tf.enable_eager_execution()
class Dataset(object):
def get_dataset(self, params, mode):
if mode == tf.estimator.ModeKeys.TRAIN:
features_path = params["train_features_file"]
labels_path = params["train_labels_file"]
elif mode == tf.estimator.Mod... | Review this code and list any quality issues. | [
{
"issue": "Function 'get_dataset' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 9
},
{
"issue": "Function 'get_dataset' is 73 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",... | 2 |
python | # -*- coding: utf-8 -*-
# Use hash instead of parameters for iterables folder names
# Otherwise path will be too long and generate OSError
from nipype import config
import clinica.pipelines.engine as cpe
cfg = dict(execution={"parameterize_dirs": False})
config.update_config(cfg)
class DeepLearningPrepareData(cpe... | Review this code and list any quality issues. | [
{
"issue": "Function 'build_input_node' has cyclomatic complexity 14 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 44
},
{
"issue": "Function 'build_input_node' is 104 lines long. Functions over 25 lines are harder to test and maintain.",
"severi... | 5 |
python | import os
import glob
import argparse
import xml.etree.ElementTree as ET
parser = argparse.ArgumentParser()
# Define parameter
parser.add_argument('--input_dir', type=str)
parser.add_argument('--output_dir', type=str)
parser.add_argument('--class_list', type=str)
args = parser.parse_args()
# Set Class Names
def s... | Review this code and list any quality issues. | [
{
"issue": "Function 'normalizeBB' has 6 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 31
}
] | 1 |
python | import pytest
from scrapli.driver.generic.base_driver import ReadCallback
from scrapli.exceptions import ScrapliValueError
def test_get_prompt(monkeypatch, sync_generic_driver):
# stupid test w/ the patch, but want coverage and in the future maybe the driver actually
# does something to the prompt it gets fr... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_readcallback_basic' is 26 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 101
}
] | 1 |
python | """Test the bootstrapping."""
# pylint: disable=protected-access
import asyncio
import logging
import os
from unittest.mock import Mock, patch
from homeassistant import bootstrap
import homeassistant.config as config_util
import homeassistant.util.dt as dt_util
from tests.common import (
MockModule,
get_test_... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_setup_after_deps_all_present' is 30 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 122
},
{
"issue": "Function 'test_setup_after_deps_not_trigger_load' is 28 lines long. Functions over 25 lines are harder to test and... | 2 |
python | #!/usr/bin/env python3
# Copyright (c) 2014-2019 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 the abandontransaction RPC.
The abandontransaction RPC marks a transaction and all its in-wallet... | Review this code and list any quality issues. | [
{
"issue": "Function 'run_test' has cyclomatic complexity 10 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 33
},
{
"issue": "Function 'run_test' is 96 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
... | 2 |
python | # Generated with SMOP 0.41
from libsmop import *
# tsne_p.m
@function
def tsne_p(P=None,labels=None,no_dims=None,*args,**kwargs):
varargin = tsne_p.varargin
nargin = tsne_p.nargin
#TSNE_P Performs symmetric t-SNE on affinity matrix P
# mappedX = tsne_p(P, labels, no_dims)
# The f... | Review this code and list any quality issues. | [
{
"issue": "Function 'tsne_p' has cyclomatic complexity 16 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 7
},
{
"issue": "Function 'tsne_p' is 61 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "critical",
... | 3 |
python | from abjad import attach
from abjad import inspect
from abjad import iterate
from abjad.tools import abctools
from abjad.tools import scoretools
class ClefSpannerExpression(abctools.AbjadValueObject):
r'''A clef spanner expression.
'''
### CLASS VARIABLES ###
__slots__ = ()
### INITIALIZER ###
... | Review this code and list any quality issues. | [
{
"issue": "Function '__call__' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 23
},
{
"issue": "Function '__call__' is 26 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
... | 2 |
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... | Review this code and list any quality issues. | [
{
"issue": "Function '_trigger_dag' has cyclomatic complexity 15 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 30
},
{
"issue": "Function '_trigger_dag' is 53 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "maj... | 5 |
python | # -*- coding: utf-8 -*-
"""
Display if files or directories exists.
Configuration parameters:
cache_timeout: refresh interval for this module (default 10)
format: display format for this module
(default '\?color=path [\?if=path ●|■]')
format_path: format for paths (default '{basename}')
format_... | Review this code and list any quality issues. | [
{
"issue": "Function 'file_status' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 116
},
{
"issue": "Function 'file_status' is 29 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor... | 2 |
python | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import keras
from keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img
import argparse
import gzip
import os
import sys
import time
import os
import math
import numpy
from... | Review this code and list any quality issues. | [
{
"issue": "Function 'main' has cyclomatic complexity 10 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 65
},
{
"issue": "Function 'main' is 69 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line":... | 2 |
python | import logging
from typing import Dict, List, Optional, Tuple
import pandas as pd
from autokeras import StructuredDataClassifier, StructuredDataRegressor
from tensorflow.keras import Model
from ._base import BaseImputer
logger = logging.getLogger()
class AutoKerasImputer(BaseImputer):
def __init__(
se... | 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": 15
},
{
"issue": "Function 'fit' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 53
... | 2 |
python | import numpy as np
import matplotlib.pyplot as plt
import pickle
import os
from scipy import stats
from HER_mod.rl_modules.tsp import generate_path
from HER_mod.rl_modules.hyperparams import NUM_GOALS, NUM_AGENTS
gd_step_list = [0,2,5, 10, 20, 40]
# NUM_AGENTS = 3
N=200
def get_path_costs(train_pos_agent, train_vel_a... | Review this code and list any quality issues. | [
{
"issue": "Function 'get_path_costs' is 50 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 13
},
{
"issue": "Function 'method_comparison' has cyclomatic complexity 26 (threshold: 5). Consider breaking it into smaller functions.",
"severity... | 4 |
python | """
The ``mlflow.spacy`` module provides an API for logging and loading spaCy models.
This module exports spacy models with the following flavors:
spaCy (native) format
This is the main flavor that can be loaded back into spaCy.
:py:mod:`mlflow.pyfunc`
Produced for use by generic pyfunc-based deployment tools ... | Review this code and list any quality issues. | [
{
"issue": "Function 'save_model' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 48
},
{
"issue": "Function 'save_model' is 31 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
... | 3 |
python | """Matplotlib distplot."""
import warnings
import matplotlib.pyplot as plt
import numpy as np
from . import backend_show
from ...kdeplot import plot_kde
from ...plot_utils import matplotlib_kwarg_dealiaser
from ....numeric_utils import get_bins
def plot_dist(
values,
values2,
color,
kind,
cumulati... | Review this code and list any quality issues. | [
{
"issue": "Function 'plot_dist' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 11
},
{
"issue": "Function 'plot_dist' is 70 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "critica... | 4 |
python | # -*- coding: utf-8 -*-
from django.contrib.auth.decorators import login_required
from django.shortcuts import render, redirect, get_object_or_404
from django.http import HttpResponsePermanentRedirect
from djconfig import config
from ..core.utils.views import is_post, post_data
from ..core.utils.paginator import pag... | Review this code and list any quality issues. | [
{
"issue": "Function 'publish' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 24
},
{
"issue": "Function 'publish' is 29 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"l... | 2 |
python | #!/usr/bin/env python
import threading, logging, time
import io
import avro.schema
import avro.io
import pprint
import kudu
from kudu.client import Partitioning
from kafka import KafkaConsumer
pp = pprint.PrettyPrinter(indent=4,width=80)
twitter_schema='''
{"namespace": "example.avro", ... | 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": 49
}
] | 1 |
python | import serial
import serial.tools.list_ports
import numpy as np
import math
import threading
import re
import os
import sys
import time
import matplotlib.pyplot as plt
pwd = os.path.abspath(os.path.abspath(__file__))
father_path = os.path.abspath(os.path.dirname(pwd) + os.path.sep + "..")
sys.path.append(father_path)
... | Review this code and list any quality issues. | [
{
"issue": "Function 'read_and_record' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 118
},
{
"issue": "Function 'read_and_record' is 34 lines long. Functions over 25 lines are harder to test and maintain.",
"severity"... | 3 |
python | """
Goal: Provides paginate() function
"""
from sqlalchemy import orm
from olass.models.pagination import Pagination
class BaseQuery(orm.Query):
"""
@see: flask-sqlalchemy/flask_sqlalchemy/__init__.py
"""
def paginate(self, page=None, per_page=None, error_out=True):
"""Returns ``per_page`` it... | Review this code and list any quality issues. | [
{
"issue": "Function 'paginate' has cyclomatic complexity 10 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 13
}
] | 1 |
python | '''
@author: MengLai
'''
import os
import tempfile
import uuid
import time
import zstackwoodpecker.test_util as test_util
import zstackwoodpecker.test_lib as test_lib
import zstackwoodpecker.test_state as test_state
import zstacklib.utils.ssh as ssh
import zstackwoodpecker.operations.scenario_operations ... | Review this code and list any quality issues. | [
{
"issue": "Function 'test' is 27 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 22
}
] | 1 |
python | import requests
import json
import time
import os
import toml
import zipfile
import csv
import pandas as pd
from datetime import date
from datetime import datetime
import logging
def incident_create(ism_url,ism_key,ism_attachment_url,final_directory,tag_name_list,flag_AH,assignee,assignee_desc,profile_link):
Patch... | Review this code and list any quality issues. | [
{
"issue": "Function 'incident_create' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 13
},
{
"issue": "Function 'incident_create' is 60 lines long. Functions over 25 lines are harder to test and maintain.",
"severit... | 3 |
python | # -*- coding: utf-8 -*-
from sst_unittest import *
from sst_unittest_support import *
import os.path
################################################################################
# Code to support a single instance module initialize, must be called setUp method
module_init = 0
module_sema = threading.Semaphore()
... | Review this code and list any quality issues. | [
{
"issue": "Function 'memHierarchy_Template' is 38 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 115
},
{
"issue": "Function '_remove_lines_cleanup_file' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.... | 4 |
python | # -*- coding: utf-8 -*-
"""
컴퓨터 비전(Vision)을 위한 전이학습(Transfer Learning)
=======================================================
**Author**: `Sasank Chilamkurthy <https://chsasank.github.io>`_
**번역**: `박정환 <http://github.com/9bow>`_
이 튜토리얼에서는 전이학습(Transfer Learning)을 이용하여 이미지 분류를 위한
합성곱 신경망을 어떻게 학습시키는지 배워보겠습니다. 전이학습에 ... | Review this code and list any quality issues. | [
{
"issue": "Function 'train_model' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 139
},
{
"issue": "Function 'train_model' is 43 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor... | 3 |
python | from manimlib.imports import *
class StartingScene(Scene):
def construct(_):
e = Text("Manim homework by mp",font="Consolas",color=BLUE)
_.play(Write(e),run_time=3)
_.wait()
_.play(Uncreate(e))
A = Dot().move_to(np.array([0-2,0,0]))
B = Dot().m... | Review this code and list any quality issues. | [
{
"issue": "Function 'construct' is 65 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 5
}
] | 1 |
python | """
1027. Longest Arithmetic Subsequence
Medium
Given an array nums of integers, return the length of the longest arithmetic subsequence in nums.
Recall that a subsequence of an array nums is a list nums[i1], nums[i2], ..., nums[ik] with 0 <= i1 < i2 < ... < ik <= nums.length - 1, and that a sequence seq is arithmet... | Review this code and list any quality issues. | [
{
"issue": "Function 'longestArithSeqLength' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 53
},
{
"issue": "Function 'longestArithSeqLength' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller fu... | 5 |
python | import copy
import numpy as np
from numpy import log10
import os
from toolz import pipe as p
from tensorboardX import SummaryWriter
import torch
import torch.nn as nn
import numpy as np
import preprocessing as pp
def findParam(model, name_filter):
if callable(name_filter):
fn = name_filter
else:
... | Review this code and list any quality issues. | [
{
"issue": "Function 'findParam' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 17
},
{
"issue": "Function 'runEpochs' has 10 parameters. Consider using a parameter object to reduce arity.",
"severity": "critical",
... | 7 |
python |
import os
import csv
import numpy as np
from FAE.FeatureAnalysis.Normalizer import Normalizer
from FAE.DataContainer.DataContainer import DataContainer
from FAE.FeatureAnalysis.Classifier import Classifier
from FAE.Func.Metric import EstimateMetirc
from FAE.FeatureAnalysis.FeatureSelector import FeatureSelecto... | Review this code and list any quality issues. | [
{
"issue": "Function 'LoadTrainInfo' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 11
},
{
"issue": "Function 'LoadTrainInfo' is 26 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "mi... | 3 |
python | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
PyHtmlCv is a tool to that can be used to generate HTML CVs from a
simple JSON configuration.
:copyright: (c) 2012-2019 Janne Enberg
:license: BSD
"""
from argparse import ArgumentParser, ArgumentTypeError
import codecs
from datetime import datetime
from jinja2 import... | Review this code and list any quality issues. | [
{
"issue": "Function 'generate_cv' has cyclomatic complexity 11 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 83
},
{
"issue": "Function 'generate_cv' is 45 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major... | 7 |
python | import cv2
import numpy
from random import shuffle
from .utils import BackgroundGenerator
from .umeyama import umeyama
class TrainingDataGenerator():
def __init__(self, random_transform_args, coverage, scale=5, zoom=1): #TODO thos default should stay in the warp function
self.random_transform_args = rando... | 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": 9
},
{
"issue": "Function 'random_transform' has 6 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 51
},
{... | 3 |
python | from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
# importing the necessary libraries
# from rasa_core.actions.action import Action
from rasa_sdk import Action
#from rasa_sdk.forms import ( BooleanFormField, EntityFormField, FormAction, FreeTextFormField )
... | Review this code and list any quality issues. | [
{
"issue": "Function 'filterRestaurantBasedOnBudget' has cyclomatic complexity 16 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 24
},
{
"issue": "Function 'filterRestaurantBasedOnBudget' is 45 lines long. Functions over 25 lines are harder to test... | 3 |
python | # ----------------------------------------------------------------------
# Label REST API
# ----------------------------------------------------------------------
# Copyright (C) 2007-2021 The NOC Project
# See LICENSE for details
# ----------------------------------------------------------------------
# Third-party m... | Review this code and list any quality issues. | [
{
"issue": "Function 'item_to_default' is 58 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 86
},
{
"issue": "Function 'item_to_form' is 54 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"li... | 2 |
python | import time
import cgi
import json
import BaseHTTPServer
import os
from player import Player
HOST_NAME = '0.0.0.0'
PORT_NUMBER = os.environ.has_key('PORT') and int(os.environ['PORT']) or 9000
class PlayerService(BaseHTTPServer.BaseHTTPRequestHandler):
def do_POST(self):
self.send_response(200)
... | Review this code and list any quality issues. | [
{
"issue": "Function 'do_POST' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 15
}
] | 1 |
python | """
Unit tests for RNN decoders.
"""
import unittest
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from texar.torch.hyperparams import HParams
from texar.torch.modules.decoders.decoder_helpers import get_helper
from texar.torch.modules.decoders.rnn_decoders import (
Attent... | Review this code and list any quality issues. | [
{
"issue": "Function '_test_outputs' has 6 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 37
},
{
"issue": "Function 'test_decode_train_with_torch' is 33 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",... | 6 |
python | # coding: utf-8
import re
import six
from huaweicloudsdkcore.utils.http_utils import sanitize_for_serialization
class DeleteDomainsRequest:
"""
Attributes:
openapi_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The k... | Review this code and list any quality issues. | [
{
"issue": "Function 'to_dict' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 64
}
] | 1 |
python | import gym
from keras.optimizers import Adam
import traceback
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '../'))
from agent.agent57 import ActorUser
from agent.policy import EpsilonGreedy, AnnealingEpsilonGreedy
from agent.memory import PERRankBaseMemory, PERProportionalMemory
from ... | Review this code and list any quality issues. | [
{
"issue": "Function 'create_parameter' is 66 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 26
}
] | 1 |
python | # AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
from ..preprocess import ROIStats
def test_ROIStats_inputs():
input_map = dict(
args=dict(argstr='%s', ),
debug=dict(argstr='-debug', ),
environ=dict(
nohash=True,
usedefault=True,
),
format1D=dic... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_ROIStats_inputs' is 60 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 5
}
] | 1 |
python | """
This file defines functions to manipulate user interaction with the web-interface.
Responsible for views related to the models defined in Materials/models.py.
"""
import os
from django.core.paginator import Paginator
from django.http import HttpResponseForbidden
from django.shortcuts import HttpResponse, redirec... | Review this code and list any quality issues. | [
{
"issue": "Function 'search' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 22
},
{
"issue": "Function 'detail' has cyclomatic complexity 14 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "m... | 3 |
python | #!/usr/bin/env python
# coding=utf-8
# Copyright © 2017 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space>
#
# 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... | Review this code and list any quality issues. | [
{
"issue": "Function 'get_l2_cache_size' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 41
}
] | 1 |
python | """
Python bindings for GLFW.
"""
from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals
import ctypes
import os
import glob
import sys
import subprocess
import textwrap
def _find_library_candidates(library_names,
library_file_exten... | Review this code and list any quality issues. | [
{
"issue": "Function '_find_library_candidates' has cyclomatic complexity 13 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 17
},
{
"issue": "Function '_find_library_candidates' is 27 lines long. Functions over 25 lines are harder to test and maintain... | 3 |
python | import os
import math
import cereal.messaging as messaging
from common.numpy_fast import clip, interp
from selfdrive.swaglog import cloudlog
from common.realtime import sec_since_boot
from selfdrive.controls.lib.radar_helpers import _LEAD_ACCEL_TAU
from selfdrive.controls.lib.longitudinal_mpc import libmpc_py
from sel... | Review this code and list any quality issues. | [
{
"issue": "Function 'update' has cyclomatic complexity 15 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 66
},
{
"issue": "Function 'update' is 50 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"li... | 2 |
python | # encoding: utf-8
import os
import sys
from os import path as osp
from pprint import pprint
import numpy as np
import torch
from tensorboardX import SummaryWriter
from torch import nn
from torch.backends import cudnn
from torch.utils.data import DataLoader
sys.path.insert(0,os.path.abspath(os.path.dirname(__file__)+o... | Review this code and list any quality issues. | [
{
"issue": "Function 'train' has cyclomatic complexity 19 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 31
},
{
"issue": "Function 'train' is 99 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "critical",
... | 2 |
python | import os
import re
def translate(pat, match_end=r"\Z"):
"""Translate a shell-style pattern to a regular expression.
The pattern may include ``**<sep>`` (<sep> stands for the platform-specific path separator; "/" on POSIX systems) for
matching zero or more directory levels and "*" for matching zero or mo... | Review this code and list any quality issues. | [
{
"issue": "Function 'translate' has cyclomatic complexity 17 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "critical",
"line": 5
},
{
"issue": "Function 'translate' is 37 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "critica... | 2 |
python | import os
import re
from collections import OrderedDict
from typing import Generator, List, Optional, Reversible
import delegator
from git import Commit
from git.exc import InvalidGitRepositoryError
from git.repo import Repo
from github import Github
from github.Label import Label
from github.Issue import Issue
from g... | Review this code and list any quality issues. | [
{
"issue": "Function 'get_issues_from_labels' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 34
}
] | 1 |
python | # encoding=utf8
# pylint: disable=mixed-indentation, trailing-whitespace, line-too-long, multiple-statements, attribute-defined-outside-init, logging-not-lazy, no-self-use, redefined-builtin, singleton-comparison, unused-argument, arguments-differ, no-else-return
import logging
from scipy.spatial.distance import euclid... | Review this code and list any quality issues. | [
{
"issue": "Function 'setParameters' has 9 parameters. Consider using a parameter object to reduce arity.",
"severity": "critical",
"line": 33
},
{
"issue": "Function 'getNeighbors' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 62
}... | 4 |
python | import os
import platform
import sys
from ctypes import (CDLL, CFUNCTYPE, POINTER, sizeof, c_bool, c_char, c_int32,
c_void_p)
from .enums import (CorsairAccessMode, CorsairError, CorsairLedId,
CorsairEventId, CorsairDevicePropertyId)
from .structs import (CorsairProtocolDetails, ... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' is 60 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 35
}
] | 1 |
python | from __future__ import print_function
import tensorflow as tf
import numpy as np
import random
import TensorflowUtils as utils
import read_MITSceneParsingDataParis as scene_parsing
import datetime
import BatchDatsetReader as dataset
from six.moves import xrange
FLAGS = tf.flags.FLAGS
tf.flags.DEFINE_integer("batch_siz... | Review this code and list any quality issues. | [
{
"issue": "Function 'vgg_net' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 27
},
{
"issue": "Function 'vgg_net' is 28 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"l... | 5 |
python | import h5py
import numpy as np
class HDF5Saver:
def __init__(self, sensor_width, sensor_height, file_path_to_save="data/carla_dataset.hdf5"):
self.sensor_width = sensor_width
self.sensor_height = sensor_height
self.file = h5py.File(file_path_to_save, "w")
# Creating groups to stor... | Review this code and list any quality issues. | [
{
"issue": "Function 'record_data' has 6 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 33
}
] | 1 |
python | #!/usr/bin/env python3
# Copyright (c) 2014-2018 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 mempool persistence.
By default, bitcoind will dump mempool on shutdown and
then reload it on sta... | Review this code and list any quality issues. | [
{
"issue": "Function 'run_test' is 58 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 54
}
] | 1 |
python | import copy
import typing
from ..model.snowflake import Snowflake
if typing.TYPE_CHECKING:
from ..api import APIClient
class CopyableObject:
def copy(self):
return copy.deepcopy(self)
class EventBase:
def __init__(self, client: "APIClient", resp: dict):
self.raw: dict = resp
se... | Review this code and list any quality issues. | [
{
"issue": "Function 'create' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 64
},
{
"issue": "Function '__init__' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "... | 3 |
python | """
:py:mod:`rootpy` overrides the default logging class, inserting a check that
there exists a default logging handler. If there is not, it adds one.
In additon, this can be used to intercept ROOT's log messages and redirect them
through python's logging subsystem
Example use:
.. sourcecode:: python
# Disable ... | Review this code and list any quality issues. | [
{
"issue": "Function 'log_trace.log_trace.wrap.thunk' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 147
}
] | 1 |
python | from telegram.ext import MessageHandler, Filters, CommandHandler, Updater
from mastodon import MastodonIllegalArgumentError, MastodonUnauthorizedError
import DataHandler
import threading
import os
import sys
import logging
import certifi
import urllib3
import re
bot_token = '<your bot token here>'
# secretfile = open... | Review this code and list any quality issues. | [
{
"issue": "Function 'add_to_group_media_queue' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 65
},
{
"issue": "Function 'add' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",... | 5 |
python |
# Generic parser schema
# with the default values
# Author: Evgeny Blokhin
import os, sys
import re
import time
import math
import random
import hashlib
import base64
from ase.data import chemical_symbols
class Output:
def __init__(self, filename='', calcset=False):
self._filename = filename # for qui... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' is 76 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 18
},
{
"issue": "Function '__repr__' has cyclomatic complexity 8 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
... | 3 |
python | # coding: utf-8
# Copyright 2020 Tarkan Temizoz
# 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 agre... | Review this code and list any quality issues. | [
{
"issue": "Function 'train' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 63
},
{
"issue": "Function 'train' is 33 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line"... | 3 |
python | import os
import re
import cv2
import umap
import torch
import torch.nn as nn
from torchvision import models
import torch.nn.functional as F
import numpy as np
from sklearn.manifold import TSNE
import matplotlib.pyplot as plt
def global_std_pool2d(x):
"""2D global standard variation pooling"""
return torch.st... | Review this code and list any quality issues. | [
{
"issue": "Function 'plot_embedding' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 69
},
{
"issue": "Function 'plot_embedding' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor"... | 2 |
python | #!/usr/bin/env python
# Lint as: python3
"""Client actions related to administrating the client and its configuration."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import logging
import os
import platform
import socket
import traceback
import crypto... | Review this code and list any quality issues. | [
{
"issue": "Function 'Run' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 188
},
{
"issue": "Function 'Run' is 27 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 1... | 2 |
python | """Tests for tinypages build using sphinx extensions."""
import filecmp
import os
from pathlib import Path
import shutil
from subprocess import Popen, PIPE
import sys
import pytest
pytest.importorskip('sphinx',
minversion=None if sys.version_info < (3, 10) else '4.1.3')
def test_tinypages(tmpd... | Review this code and list any quality issues. | [
{
"issue": "Function 'test_tinypages' is 47 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 17
}
] | 1 |
python | from model import DeepJIT
import torch
from tqdm import tqdm
from utils import mini_batches_train, save
import torch.nn as nn
import os, datetime
def train_model(data, params):
data_pad_msg, data_pad_code, data_labels, dict_msg, dict_code = data
# set up parameters
params.cuda = (not params.no_cuda) ... | Review this code and list any quality issues. | [
{
"issue": "Function 'train_model' has cyclomatic complexity 9 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 8
},
{
"issue": "Function 'train_model' is 35 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",... | 2 |
python | import xml.etree.ElementTree as ET
import bz2, sys
def SortOsm(inFina, outFina):
fi = bz2.BZ2File(inFina)
root = ET.fromstring(fi.read())
fi.close()
objDict = {}
for obj in root:
if 'id' in obj.attrib:
i = int(obj.attrib['id'])
#print obj.tag, i
if obj.tag not in objDict:
objDict[obj.tag] = {}
... | Review this code and list any quality issues. | [
{
"issue": "Function 'SortOsm' has cyclomatic complexity 10 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 4
},
{
"issue": "Function 'SortOsm' is 31 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"l... | 2 |
python | # -*- coding: utf-8 -*-
'''
Load up the libvirt keys into Pillar for a given minion if said keys have been generated using the libvirt key runner
'''
from __future__ import absolute_import
# Don't "fix" the above docstring to put it on two lines, as the sphinx
# autosummary pulls only the first line for its descriptio... | Review this code and list any quality issues. | [
{
"issue": "Function 'gen_hyper_keys' has cyclomatic complexity 12 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 50
},
{
"issue": "Function 'gen_hyper_keys' is 73 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": ... | 3 |
python | #!/usr/bin/env python3
import json, sys, os, base64, hashlib, glob
def writeSource(f, src):
for line in src:
f.write(line)
def processOutputs(f, outputs):
for output in outputs:
if( "text" in output.keys() ):
f.write("```\n")
for line in output["text"]:
f.write(line)
f.write("\n```\n")
if( "d... | Review this code and list any quality issues. | [
{
"issue": "Function 'processOutputs' has cyclomatic complexity 14 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 8
},
{
"issue": "Function 'processOutputs' is 32 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "... | 3 |
python | ##
# @file
# This file is part of SeisSol.
#
# @author Carsten Uphoff (c.uphoff AT tum.de, http://www5.in.tum.de/wiki/index.php/Carsten_Uphoff,_M.Sc.)
#
# @section LICENSE
# Copyright (c) 2015-2018, SeisSol Group
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modificatio... | Review this code and list any quality issues. | [
{
"issue": "Function '__init__' is 28 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "major",
"line": 43
},
{
"issue": "Function '__init__' has 7 parameters. Consider using a parameter object to reduce arity.",
"severity": "major",
"line": 43
}
] | 2 |
python | # -*- coding: utf-8 -*-
# pylint: disable=expression-not-assigned,line-too-long
SPDX_2_2_DCI_TV = {
"SPDXVersion": "SPDX-2.2",
"DataLicense": "CC0-1.0",
"SPDXID": "SPDXRef-DOCUMENT",
"DocumentName": "$_SINGLE_LINE",
"DocumentNamespace": "$_URI_MINUS_PART",
"[ExternalDocumentRef]": [
"Do... | Review this code and list any quality issues. | [
{
"issue": "Function 'spdx_dci_is_valid' has cyclomatic complexity 6 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 42
}
] | 1 |
python | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA 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 cop... | 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": 58
},
{
"issue": "Function 'main' is 80 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "critical",
"... | 2 |
python | #!/usr/bin/env python
from rabbitmq import RabbitMQ, Consumer, Publisher
import time
import json
import pika
import random
import threading
import sys
from datetime import datetime
from tinydb import TinyDB, Query
QUEUE_URL = '152.118.148.103'
QUEUE_PORT = '5672'
USERNAME = '1306398983'
PASSWORD = '446167'
VHOST = '13... | Review this code and list any quality issues. | [
{
"issue": "Function 'callback' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 42
}
] | 1 |
python | """
A simple kivy wrapper
"""
import kivy
from kivy.app import App
from kivy.core.window import Window
from kivy.uix.widget import Widget
from kivy.uix.gridlayout import GridLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.clock import Clock
"""
A really simple discrete env... | Review this code and list any quality issues. | [
{
"issue": "Function '_on_keyboard_down' has 5 parameters. Consider using a parameter object to reduce arity.",
"severity": "minor",
"line": 67
}
] | 1 |
python | from people.models import Village, Mother, Driver, HealthCenter, MotherDriverConnection
from django.http import JsonResponse, Http404
from django.core import serializers
from decouple import config
from .geokdbush.geokdbush import around, distance
import requests
import json
import time
FRONTLINE_KEY = config('FRONTLI... | Review this code and list any quality issues. | [
{
"issue": "Function 'mother' is 47 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 40
},
{
"issue": "Function 'regMother' is 33 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": 102
}... | 3 |
python | import argparse
import os
import tempfile
from getpass import getuser
import skein
from skein.tornado import SimpleAuthMixin, KerberosAuthMixin, init_kerberos
from tornado import web, ioloop
# An argument parser for configuring the application
parser = argparse.ArgumentParser(
description="A web service for subm... | Review this code and list any quality issues. | [
{
"issue": "Function 'post' has cyclomatic complexity 7 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "minor",
"line": 65
},
{
"issue": "Function 'post' is 32 lines long. Functions over 25 lines are harder to test and maintain.",
"severity": "minor",
"line": ... | 2 |
python |
import git
import os
import logging
import glob
# Logger
logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))
LOGGER = logging.getLogger(__name__)
SECURITY_CONTENT_URL = "https://github.com/splunk/security_content"
class GithubService:
def __init__(self, security_content_branch):
self.securi... | Review this code and list any quality issues. | [
{
"issue": "Function 'get_changed_test_files_ssa' has cyclomatic complexity 11 (threshold: 5). Consider breaking it into smaller functions.",
"severity": "major",
"line": 27
},
{
"issue": "Function 'get_changed_test_files_ssa' is 26 lines long. Functions over 25 lines are harder to test and main... | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.