Showing 808 of 808 total issues
File handler.py
has 2967 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python
# 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
DatabaseRdbms
has 192 functions (exceeds 20 allowed). Consider refactoring. Open
class DatabaseRdbms(object):
def __init__(self, env: GNEnvironment):
self.env = env
if self.env.config.get(ConfigKeys.TESTING, False):
DatabaseRdbms.db = MockDatabase()
File __init__.py
has 1432 lines of code (exceeds 250 allowed). Consider refactoring. Open
import ast
import logging
import os
import re
import sys
DatabaseRedis
has 183 functions (exceeds 20 allowed). Consider refactoring. Open
class DatabaseRedis(object):
redis = None
def __init__(self, env: GNEnvironment, host: str, port: int = 6379, db: int = 0):
if environ.env.config.get(ConfigKeys.TESTING, False) or host == 'mock':
IDatabase
has 164 functions (exceeds 20 allowed). Consider refactoring. Open
class IDatabase(Interface):
def init_config(self) -> None:
"""
initialize the config table
File __init__.py
has 1235 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python
# 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
File redis.py
has 1164 lines of code (exceeds 250 allowed). Consider refactoring. Open
import json
import logging
import traceback
import random
import sys
CacheRedis
has 143 functions (exceeds 20 allowed). Consider refactoring. Open
class CacheRedis(object):
def __init__(self, env, host: str, port: int = 6379, db: int = 0):
if env.config.get(ConfigKeys.TESTING, False) or host == 'mock':
from fakeredis import FakeStrictRedis
File redis.py
has 1093 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python
# 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
File routes.py
has 1024 lines of code (exceeds 250 allowed). Consider refactoring. Open
import logging
import os
import sys
import traceback
from functools import wraps
ICache
has 129 functions (exceeds 20 allowed). Consider refactoring. Open
class ICache(Interface):
def get_user_for_sid(self, sid: str):
"""
get the user id for a sid
File environ.py
has 858 lines of code (exceeds 250 allowed). Consider refactoring. Open
# 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
File __init__.py
has 823 lines of code (exceeds 250 allowed). Consider refactoring. Open
from typing import Set
from zope.interface import Interface
from typing import Union, Dict, List, Optional
Function handle_disconnect
has a Cognitive Complexity of 91 (exceeds 5 allowed). Consider refactoring. Open
def handle_disconnect(arg: tuple, is_socket_disconnect: bool=False) -> None:
"""
when a client disconnects this hook will handle the related logic
:param arg: tuple of (data, parsed_activity)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function do_process
has a Cognitive Complexity of 78 (exceeds 5 allowed). Consider refactoring. Open
def do_process(arg: tuple) -> None:
def send(_data: dict, _room: str, _json: bool=True, _broadcast: bool=True) -> None:
environ.env.emit('message', _data, json=_json, room=_room, broadcast=_broadcast)
def publish_activity() -> None:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function pre_process
has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring. Open
def pre_process(validation_name, should_validate_request=True):
def factory(view_func):
@wraps(view_func)
def decorator(*a, **k):
def _pre_process(*args, **kwargs):
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function on_message
has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring. Open
def on_message(self, activity: Activity) -> (bool, int, str):
room_id = activity.target.id
user_id = activity.actor.id
object_type = activity.target.object_type
message = activity.object.content
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Identical blocks of code found in 2 locations. Consider refactoring. Open
elif message_queue_type == 'amqp':
message_channel = 'dino_%s' % environ.env.config.get(ConfigKeys.ENVIRONMENT, default='test')
message_queue = ';'.join(['amqp://%s:%s@%s:%s%s' % (
environ.env.config.get(ConfigKeys.USER, domain=ConfigKeys.COORDINATOR, default=''),
environ.env.config.get(ConfigKeys.PASSWORD, domain=ConfigKeys.COORDINATOR, default=''),
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 149.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
elif message_queue_type == 'amqp':
message_channel = 'dino_%s' % environ.env.config.get(ConfigKeys.ENVIRONMENT, default='test')
message_queue = ';'.join(['amqp://%s:%s@%s:%s%s' % (
environ.env.config.get(ConfigKeys.USER, domain=ConfigKeys.COORDINATOR, default=''),
environ.env.config.get(ConfigKeys.PASSWORD, domain=ConfigKeys.COORDINATOR, default=''),
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 149.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
File request.py
has 592 lines of code (exceeds 250 allowed). Consider refactoring. Open
import sys
from activitystreams.models.activity import Activity
from activitystreams.models.defobject import DefObject
from activitystreams.models.actor import Actor
from activitystreams.models.target import Target