Showing 243 of 245 total issues
Function _create_attn_cell
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def _create_attn_cell(self,
Function __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, domain, host='localhost',
Function _create_tf_dial_embed
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def _create_tf_dial_embed(
Function __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Similar blocks of code found in 2 locations. Consider refactoring. Open
tf.TensorArray(dtype, size=self._sequence_len + 1,
dynamic_size=False,
clear_after_read=False
).write(0, zero_state.cell_state.h)
- 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 36.
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
tf.TensorArray(dtype, size=self._sequence_len + 1,
dynamic_size=False,
clear_after_read=False
).write(0, zero_state.cell_state.c),
- 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 36.
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
Avoid deeply nested control flow statements. Open
with warnings.catch_warnings():
warnings.simplefilter("ignore")
model = load_model(model_file)
Avoid deeply nested control flow statements. Open
if prob > best_intent_prob:
# finding the maximum confidence intent
if best_intent is not None:
# delete previous best intent
del bin_state[best_intent]
Function collect_templates
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def collect_templates(
yml_templates: Dict[Text, List[Any]]
) -> Dict[Text, List[Dict[Text, Any]]]:
"""Go through the templates and make sure they are all in dict format
"""
- 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 as_story_string
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def as_story_string(self, e2e=False):
if self.intent:
if self.entities:
ent_string = json.dumps({ent['entity']: ent['value']
for ent in self.entities})
- 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
Avoid deeply nested control flow statements. Open
if s.type_name == 'list':
slot_events.append(SlotSet(s.name,
matching_entities))
else:
slot_events.append(SlotSet(s.name,
Function __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, domain, url, port, db, password, record_exp):
Function __init__
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self,
text: Optional[Text],
output_channel: Optional['OutputChannel'] = None,
sender_id: Text = None,
parse_data: Dict[Text, Any] = 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 first_key
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def first_key(d, default_key):
if len(d) > 1:
for k, v in d.items():
if k != default_key:
# we return the first key that is not the default key
- 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 __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self,
Avoid deeply nested control flow statements. Open
if online:
logger.info("Original stories are "
"different for {} -- {}\n"
"Memorized the new ones for "
"now. Delete contradicting "
Avoid deeply nested control flow statements. Open
if self.remove_duplicates:
hashed = self._hash_example(sliced_states,
event.action_name)
# only continue with tracker_states that created a
Function test
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def test(model: Text, stories: Text, nlu_data: Text, endpoints: Text = None,
Function configure_app
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def configure_app(input_channels=None,
cors=None,
auth_token=None,
enable_api=True,
jwt_secret=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 zero_state
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def zero_state(self, batch_size, dtype):
"""Modified from tensorflow's zero_state
see there for description of the parameters"""
# use AttentionWrapperState from superclass
- 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"