Showing 192 of 192 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
else if (this.status == 403) {
//document.getElementById("checkmark_url").innerHTML = "✔️"
//document.getElementById("checkmark_key").innerHTML = "❌"
document.getElementById("serverurl").style.backgroundColor = "lawngreen"
document.getElementById("apikey").style.backgroundColor = "red"
- 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 53.
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
Function get_scrobbles_of_track
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_scrobbles_of_track(track,since=None,to=None,resolve_references=True,limit=None,reverse=False,dbconn=None):
Function get_scrobbles_of_album
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_scrobbles_of_album(album,since=None,to=None,resolve_references=True,limit=None,reverse=False,dbconn=None):
Avoid deeply nested control flow statements. Open
if duration in ('-',''): duration = None
scrobblelist.append({
Function set_image
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def set_image(b64,**keys):
if "title" in keys:
entity = {"track":keys}
id = database.sqldb.get_track_id(entity['track'])
idkeys = {'track_id':id}
- 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 album_id:
result['value'] = placeholder_url + f"joy-division&colors={album_id % 100}"
else:
Function count_scrobbles_by_album_combined
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def count_scrobbles_by_album_combined(since,to,artist,associated=False,resolve_ids=True,dbconn=None):
Function add_common_args_to_docstring
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def add_common_args_to_docstring(filterkeys=False,limitkeys=False,delimitkeys=False,amountkeys=False):
def decorator(func):
timeformats = "Possible formats include '2022', '2022/08', '2022/08/01', '2022/W42', 'today', 'thismonth', 'monday', 'august'"
if filterkeys:
- 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 count_scrobbles_by_track_of_artist
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def count_scrobbles_by_track_of_artist(since,to,artist,associated=False,resolve_ids=True,dbconn=None):
Avoid deeply nested control flow statements. Open
if (result["service_active_" + key]) {
console.log("New page on tab " + tabId + " will be handled by new " + key + " manager!");
tabManagers[tabId] = new Controller(tabId,key);
updateTabNum();
//chrome.tabs.executeScript(tab.id,{"file":"sitescripts/" + pages[key]["script"]})
Function next
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def next(self,step=1):
if abs(step) == math.inf: return None
if self.precision == 1:
return MTRangeGregorian(self.year + step)
elif self.precision == 2:
- 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 stop
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def stop():
for attempt in [(signal.SIGTERM,2),(signal.SIGTERM,5),(signal.SIGKILL,3),(signal.SIGKILL,5)]:
pid_sv = get_instance_supervisor()
- 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 artist_id:
result['value'] = placeholder_url + f"tiles&colors={artist_id % 100}"
if track_id:
Avoid deeply nested control flow statements. Open
if track_id:
result['value'] = "/static/svg/placeholder_track.svg"
if album_id:
Function count_scrobbles_by_album_of_artist
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def count_scrobbles_by_album_of_artist(since,to,artist,associated=False,resolve_ids=True,dbconn=None):
Function count_scrobbles_of_artist_by_album
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def count_scrobbles_of_artist_by_album(since,to,artist,associated=False,resolve_ids=True,dbconn=None):
Avoid deeply nested control flow statements. Open
if track_id:
result['value'] = placeholder_url + f"triangles&colors={track_id % 100}"
if album_id:
Avoid deeply nested control flow statements. Open
if artist_id:
result['value'] = "/static/svg/placeholder_artist.svg"
if track_id:
Avoid deeply nested control flow statements. Open
if (abs(scr[0] - timestamp) < 30) and scr[1:] == scrobble_describe[1:]:
yield ('UNCERTAIN_SKIP',None,f"{entry} might be a duplicate, skipping...")
found_similar = True
break
else:
Function handshake
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def handshake(self,pathnodes,keys):
auth = keys.get("a")
timestamp = keys.get("t")
apikey = keys.get("api_key")
host = keys.get("Host")
- 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"