Showing 19 of 19 total issues
Function validate_agg
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def validate_agg(func):
"""validate aggregate_by argument"""
@wraps(func)
def wrapper(*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 validate_period
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def validate_period(minYear):
today = datetime.datetime.now()
period = request.args.get('period', None)
if period:
- 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 format_dataset_query
has 13 arguments (exceeds 4 allowed). Consider refactoring. Open
def format_dataset_query(day_value, confidence, from_year, from_date, to_year, to_date, count_sql, from_sql,
Function validate_admin
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def validate_admin(func):
"""validate admin arguments"""
@wraps(func)
def wrapper(*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
Similar blocks of code found in 2 locations. Consider refactoring. Open
standard_format["attributes"]["downloadUrls"][
"csv"] = "/download/" + dataset_id + download_sql + "&format=csv"
- 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 41.
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
standard_format["attributes"]["downloadUrls"][
"json"] = "/download/" + dataset_id + download_sql + "&format=json"
- 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 41.
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 format_dataset_query
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def format_dataset_query(day_value, confidence, from_year, from_date, to_year, to_date, count_sql, from_sql,
select_sql, order_sql, groupby_sql, iso=None, state=None, dist=None):
if (int(from_year) == int(to_year)):
where_template = 'WHERE ((year = {y1} and {day} >= {d1} and {day} <= {d2}))' + confidence
- 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 create_time_table
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def create_time_table(dataset, data, agg_type):
if not data['data']:
return []
- 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 standardize_response
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def standardize_response(data, dataset_id, count=None, download_sql=None, area=None, geostore=None, agg=None,
Function format_terrai_sql
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def format_terrai_sql(from_year, from_date, to_year, to_date, iso=None, state=None, dist=None, agg_values=False):
Function analyze
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def analyze(area=None, geostore=None, iso=None, state=None, dist=None, geojson=None):
Function validate_geostore
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate_geostore(func):
"""validate geostore argument"""
@wraps(func)
def wrapper(*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 make_analysis_request
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def make_analysis_request(dataset_id, sql, geostore, geojson, api_key, v2=False):
Function standardize_response
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def standardize_response(data, dataset_id, count=None, download_sql=None, area=None, geostore=None, agg=None,
agg_by=None, period=None):
# Helper function to standardize API responses
standard_format = {}
standard_format["type"] = "terrai-alerts"
- 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 query_terrai
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def query_terrai():
"""analyze terrai by geostore or geojson"""
if request.method == 'GET':
logging.info('[ROUTER]: get Terra I by Geostore')
- 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 too many return
statements within this function. Open
return error(status=400, detail='Start date must be less than end date')
Avoid too many return
statements within this function. Open
return func(*args, **kwargs)
Function analyze
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def analyze(area=None, geostore=None, iso=None, state=None, dist=None, geojson=None):
"""Analyze method to execute queries
This is designed to format the dates of the request, create the sql and download sql queries from
the dates, retrieve the data from the queries and send the data to a formatter service to format
the API response.
- 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 worker_int
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def worker_int(worker):
worker.log.info("worker received INT or QUIT signal")
## get traceback info
import threading, sys, traceback
- 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"