Showing 243 of 245 total issues
File embedding_policy.py
has 1090 lines of code (exceeds 250 allowed). Consider refactoring. Open
from collections import namedtuple
import copy
import json
import logging
import os
File interactive.py
has 1050 lines of code (exceeds 250 allowed). Consider refactoring. Open
import asyncio
import logging
import os
import tempfile
import textwrap
File __init__.py
has 747 lines of code (exceeds 250 allowed). Consider refactoring. Open
import time
import typing
import json
import jsonpickle
File tf_utils.py
has 679 lines of code (exceeds 250 allowed). Consider refactoring. Open
from collections import namedtuple
import tensorflow as tf
class TimedNTM(object):
Function as_story_string
has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring. Open
def as_story_string(self, flat=False, e2e=False):
# if the result should be flattened, we
# will exclude the caption and any checkpoints.
for s in self.start_checkpoints:
- 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
File server.py
has 605 lines of code (exceeds 250 allowed). Consider refactoring. Open
import glob
import logging
import os
import tempfile
import zipfile
File agent.py
has 574 lines of code (exceeds 250 allowed). Consider refactoring. Open
import asyncio
import logging
import os
import shutil
import tempfile
File test_policies.py
has 549 lines of code (exceeds 250 allowed). Consider refactoring. Open
from unittest.mock import patch
import numpy as np
import pytest
File test.py
has 543 lines of code (exceeds 250 allowed). Consider refactoring. Open
import argparse
import asyncio
import json
import logging
import os
Function generate
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
def generate(self, silent: bool = False) -> List[TrackerWithCachedStates]:
if (self.config.remove_duplicates and
self.config.unique_last_num_states):
logger.debug("Generated trackers will be deduplicated "
"based on their unique last {} states."
- 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
File structures.py
has 524 lines of code (exceeds 250 allowed). Consider refactoring. Open
from collections import deque, defaultdict
import io
import sys
import json
File test_channels.py
has 511 lines of code (exceeds 250 allowed). Consider refactoring. Open
import json
import logging
import mock
import pytest
import sanic
Similar blocks of code found in 2 locations. Consider refactoring. Open
def test_label_tokenizer_featurizer_uses_correct_dtype_float():
f = LabelTokenizerSingleStateFeaturizer()
f.user_labels = ["a_d"]
f.bot_labels = ["c_b"]
f.user_vocab = {"a": 0, "d": 1}
- 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 124.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def test_label_tokenizer_featurizer_uses_correct_dtype_int():
f = LabelTokenizerSingleStateFeaturizer()
f.user_labels = ["a_d"]
f.bot_labels = ["c_b"]
f.user_vocab = {"a": 0, "d": 1}
- 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 124.
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 domain.py
has 502 lines of code (exceeds 250 allowed). Consider refactoring. Open
import collections
import json
import logging
import os
import typing
Function create_app
has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring. Open
def create_app(agent=None,
cors_origins: Union[Text, List[Text]] = "*",
auth_token: Optional[Text] = None,
jwt_secret: Optional[Text] = None,
jwt_method: Text = "HS256",
- 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
File featurizers.py
has 469 lines of code (exceeds 250 allowed). Consider refactoring. Open
import io
import jsonpickle
import logging
import numpy as np
import os
File generator.py
has 459 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
from collections import defaultdict, namedtuple, deque
import copy
import logging
Function with_cycles_removed
has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring. Open
def with_cycles_removed(self) -> 'StoryGraph':
"""Create a graph with the cyclic edges removed from this graph."""
story_end_checkpoints = self.story_end_checkpoints.copy()
cyclic_edge_ids = self.cyclic_edge_ids
- 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
EmbeddingPolicy
has 48 functions (exceeds 20 allowed). Consider refactoring. Open
class EmbeddingPolicy(Policy):
"""Recurrent Embedding Dialogue Policy (REDP)
The policy that is used in our paper https://arxiv.org/abs/1811.11707
"""