# holgern/beem

beem/utils.py

### Summary

F
4 days
C
70%

#### File `utils.py` has 438 lines of code (exceeds 250 allowed). Consider refactoring. Open

``````# -*- coding: utf-8 -*-
import re
import json
import time as timenow
import math``````
Found in beem/utils.py - About 6 hrs to fix

#### Cyclomatic complexity is too high in function create_yaml_header. (19) Open

``````def create_yaml_header(comment, json_metadata={}, reply_identifier=None):
yaml_prefix = '---\n'
if comment["title"] != "":
yaml_prefix += 'title: "%s"\n' % comment["title"]

## Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

#### Function `derive_permlink` has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open

``````def derive_permlink(title, parent_permlink=None, parent_author=None,
"""Derive a permlink from a comment title (for root level
author (for replies).``````
Found in beem/utils.py - About 3 hrs to fix

# 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"

#### Cyclomatic complexity is too high in function import_custom_json. (15) Open

``````def import_custom_json(jsonid, json_data):
data = {}
if isinstance(json_data, tuple) and len(json_data) > 1:
key = None
for j in json_data:``````

## Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

#### Function `import_custom_json` has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open

``````def import_custom_json(jsonid, json_data):
data = {}
if isinstance(json_data, tuple) and len(json_data) > 1:
key = None
for j in json_data:``````
Found in beem/utils.py - About 3 hrs to fix

# 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"

#### Function `create_yaml_header` has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open

``````def create_yaml_header(comment, json_metadata={}, reply_identifier=None):
yaml_prefix = '---\n'
if comment["title"] != "":
yaml_prefix += 'title: "%s"\n' % comment["title"]
Found in beem/utils.py - About 2 hrs to fix

# 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"

#### Cyclomatic complexity is too high in function derive_beneficiaries. (11) Open

``````def derive_beneficiaries(beneficiaries):
beneficiaries_list = []
beneficiaries_accounts = []
beneficiaries_sum = 0
if not isinstance(beneficiaries, list):``````

## Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

#### Cyclomatic complexity is too high in function derive_permlink. (11) Open

``````def derive_permlink(title, parent_permlink=None, parent_author=None,
"""Derive a permlink from a comment title (for root level
author (for replies).``````

## Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

#### Function `derive_beneficiaries` has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open

``````def derive_beneficiaries(beneficiaries):
beneficiaries_list = []
beneficiaries_accounts = []
beneficiaries_sum = 0
if not isinstance(beneficiaries, list):``````
Found in beem/utils.py - About 2 hrs to fix

# 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"

#### Cyclomatic complexity is too high in function create_new_password. (9) Open

``````def create_new_password(length=32):
"""Creates a random password containing alphanumeric chars with at least 1 number and 1 upper and lower char"""
alphabet = string.ascii_letters + string.digits
while True:
import_password = ''.join(secrets.choice(alphabet) for i in range(length))``````

## Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

#### Cyclomatic complexity is too high in function remove_from_dict. (8) Open

``````def remove_from_dict(obj, keys=list(), keep_keys=True):
""" Prune a class or dictionary of all but keys (keep_keys=True).
Prune a class or dictionary of specified keys.(keep_keys=False).
"""
if type(obj) == dict:``````

## Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

#### Cyclomatic complexity is too high in function import_coldcard_wif. (8) Open

``````def import_coldcard_wif(filename):
"""Reads a exported coldcard Wif text file and returns the WIF and used path"""
next_var = ""
path = ""``````

## Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

#### Cyclomatic complexity is too high in function derive_tags. (6) Open

``````def derive_tags(tags):
tags_list = []
if len(tags.split(",")) > 1:
for tag in tags.split(","):
tags_list.append(tag.strip())``````

## Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

#### Function `import_coldcard_wif` has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open

``````def import_coldcard_wif(filename):
"""Reads a exported coldcard Wif text file and returns the WIF and used path"""
next_var = ""
path = ""``````
Found in beem/utils.py - About 55 mins to fix

# 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"

#### Function `derive_permlink` has 5 arguments (exceeds 4 allowed). Consider refactoring. Open

``def derive_permlink(title, parent_permlink=None, parent_author=None,``
Found in beem/utils.py - About 35 mins to fix

#### Function `derive_tags` has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open

``````def derive_tags(tags):
tags_list = []
if len(tags.split(",")) > 1:
for tag in tags.split(","):
tags_list.append(tag.strip())``````
Found in beem/utils.py - About 35 mins to fix

# 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"

#### Function `construct_authorpermvoter` has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open

``````def construct_authorpermvoter(*args):
""" Create a vote identifier from vote object or arguments.
Examples:

.. code-block:: python``````
Found in beem/utils.py - About 35 mins to fix

# 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"

#### Avoid too many `return` statements within this function. Open

``            return suffix[1:]  # use timestamp only, strip leading "-"``
Found in beem/utils.py - About 30 mins to fix

#### Avoid too many `return` statements within this function. Open

``            return body + suffix``
Found in beem/utils.py - About 30 mins to fix

#### Avoid too many `return` statements within this function. Open

``            return body``
Found in beem/utils.py - About 30 mins to fix

#### Refactor this function to reduce its Cognitive Complexity from 18 to the 15 allowed. Open

``def derive_beneficiaries(beneficiaries):``
Found in beem/utils.py by sonar-python

Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

## See

#### Refactor this function to reduce its Cognitive Complexity from 20 to the 15 allowed. Open

``def create_yaml_header(comment, json_metadata={}, reply_identifier=None):``
Found in beem/utils.py by sonar-python

Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

## See

#### Refactor this function to reduce its Cognitive Complexity from 25 to the 15 allowed. Open

``def import_custom_json(jsonid, json_data):``
Found in beem/utils.py by sonar-python

Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

## See

#### Refactor this function to reduce its Cognitive Complexity from 24 to the 15 allowed. Open

``def derive_permlink(title, parent_permlink=None, parent_author=None,``
Found in beem/utils.py by sonar-python

Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

## See

#### Either merge this branch with the identical one on line "291" or change one of the implementations. Open

``        items = list(obj.items())``
Found in beem/utils.py by sonar-python

Having two branches in the same `if` structure with the same implementation is at best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then they should be combined.

## Noncompliant Code Example

```if 0 <= a < 10:
do_the_thing()
elif 10 <= a < 20:
do_the_other_thing()
elif 20 <= a < 50:
do_the_thing()  # Noncompliant; duplicates first condition
else:
do_the_rest()

b = 4 if a > 12 else 4
```

## Compliant Solution

```if (0 <= a < 10) or (20 <= a < 50):
do_the_thing()
elif 10 <= a < 20:
do_the_other_thing()
else:
do_the_rest()

b = 4
```

or

```if 0 <= a < 10:
do_the_thing()
elif 10 <= a < 20:
do_the_other_thing()
elif 20 <= a < 50:
do_the_third_thing()
else:
do_the_rest()

b = 8 if a > 12 else 4
```

#### Identical blocks of code found in 2 locations. Consider refactoring. Open

``````    if "beneficiaries" in comment:
beneficiaries = []
for b in comment["beneficiaries"]:
beneficiaries.append("%s:%.2f%%" % (b["account"], b["weight"] / 10000 * 100))
if len(beneficiaries) > 0:``````
Found in beem/utils.py and 1 other location - About 6 hrs to fix
beem/cli.py on lines 2568..2573

## 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 102.

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

#### Identical blocks of code found in 2 locations. Consider refactoring. Open

``````    if "percent_steem_dollars" in comment:
yaml_prefix += 'percent_steem_dollars: %s\n' %  str(comment["percent_steem_dollars"])
elif "percent_hbd" in comment:
yaml_prefix += 'percent_hbd: %s\n' %  str(comment["percent_hbd"])``````
Found in beem/utils.py and 1 other location - About 3 hrs to fix
beem/cli.py on lines 2560..2563

## 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 67.

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

#### Identical blocks of code found in 2 locations. Consider refactoring. Open

``````        if with_suffix:
rem_chars = max_permlink_length - len(suffix) - len(prefix)
else:
Found in beem/utils.py and 1 other location - About 1 hr to fix
beem/utils.py on lines 135..138

## 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 45.

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

#### Identical blocks of code found in 2 locations. Consider refactoring. Open

``````        if with_suffix:
rem_chars = max_permlink_length - len(suffix) - len(prefix)
else:
Found in beem/utils.py and 1 other location - About 1 hr to fix
beem/utils.py on lines 124..127

## 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 45.

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

#### Identical blocks of code found in 2 locations. Consider refactoring. Open

``````    if comment["title"] != "":
yaml_prefix += 'title: "%s"\n' % comment["title"]``````
Found in beem/utils.py and 1 other location - About 45 mins to fix
beem/cli.py on lines 2543..2544

## 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 35.

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

#### Rename function "addTzInfo" to match the regular expression ^[a-z_][a-z0-9_]{2,}\$. Open

``def addTzInfo(t, timezone="UTC"):``
Found in beem/utils.py by sonar-python

Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

## Noncompliant Code Example

With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}\$

```def MyFunction(a,b):
...
```

## Compliant Solution

```def my_function(a,b):
...
```

#### Rename function "formatToTimeStamp" to match the regular expression ^[a-z_][a-z0-9_]{2,}\$. Open

``def formatToTimeStamp(t):``
Found in beem/utils.py by sonar-python

Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

## Noncompliant Code Example

With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}\$

```def MyFunction(a,b):
...
```

## Compliant Solution

```def my_function(a,b):
...
```

#### Rename function "formatTimeFromNow" to match the regular expression ^[a-z_][a-z0-9_]{2,}\$. Open

``def formatTimeFromNow(secs=0):``
Found in beem/utils.py by sonar-python

Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

## Noncompliant Code Example

With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}\$

```def MyFunction(a,b):
...
```

## Compliant Solution

```def my_function(a,b):
...
```

#### Rename function "formatTime" to match the regular expression ^[a-z_][a-z0-9_]{2,}\$. Open

``def formatTime(t):``
Found in beem/utils.py by sonar-python

Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

## Noncompliant Code Example

With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}\$

```def MyFunction(a,b):
...
```

## Compliant Solution

```def my_function(a,b):
...
```

#### Rename function "formatTimeString" to match the regular expression ^[a-z_][a-z0-9_]{2,}\$. Open

``def formatTimeString(t):``
Found in beem/utils.py by sonar-python

Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

## Noncompliant Code Example

With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}\$

```def MyFunction(a,b):
...
```

## Compliant Solution

```def my_function(a,b):
...
```

#### Rename function "formatTimedelta" to match the regular expression ^[a-z_][a-z0-9_]{2,}\$. Open

``def formatTimedelta(td):``
Found in beem/utils.py by sonar-python

Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

## Noncompliant Code Example

With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}\$

```def MyFunction(a,b):
...
```

## Compliant Solution

```def my_function(a,b):
...
```