Showing 45 of 45 total issues
Function format_tags
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def format_tags(all_tags, sep=','):
tags = []
if isinstance(all_tags, six.string_types):
tags = all_tags.split(sep)
elif isinstance(all_tags, list):
- 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 migrate
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def migrate(migration, sources=None, kwargs_string=None, dry=True, async=False, group_size=1000):
Function populate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def populate(grid_file):
transformer = JSONTransformer(schema)
for doc in get_jsons(grid_file):
transformed = transformer.transform(doc, load=False)
try:
- 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 migrate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def migrate(migration, sources=None, kwargs_string=None, dry=True, async=False, group_size=1000):
''' Task to run a migration.
:param migration: The migration function to run. This is passed in
as a string then interpreted as a function by the invoke task.
- 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 record_or_load_response
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def record_or_load_response(method, url, throttle=None, force=False, params=None, expected=(200,), **kwargs):
resp = _maybe_load_response(method, url)
if not force and resp and resp.ok:
- 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 cross_db
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def cross_db(docs, source_db=None, target_db=None, index=None, versions=False, **kwargs):
Function migrate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def migrate(migration, source_db=None, sources=tuple(), async=False, dry=True, group_size=1000, **kwargs):
source_db = source_db or settings.CANONICAL_PROCESSOR
documents = processing.get_processor(source_db).documents
- 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
('dataCenter', ('//dif:Data_Center/node()', compose(
list,
lambda x: map(element_to_dict, x),
lambda x: filter(non_string, x)
- 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 34.
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
('relatedUrl', ('//dif:Related_URL/node()', compose(
list,
lambda x: map(element_to_dict, x),
lambda x: filter(non_string, x)
- 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 34.
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 oai_get_records_and_token
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def oai_get_records_and_token(url, throttle, force, namespaces, verify):
Function test
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def test(cov=True, doctests=True, verbose=False, debug=False, pdb=False):
Function gather_identifiers
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def gather_identifiers(args):
identifiers = []
for arg in args:
if isinstance(arg, list):
for identifier in arg:
- 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 oai_extract_dois
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def oai_extract_dois(*args):
identifiers = gather_identifiers(args)
dois = []
for item in identifiers:
if 'doi' in item.lower():
- 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 _transform_value
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _transform_value(self, value, doc, fail=False):
if isinstance(value, dict):
return self._transform_dict(value, doc, fail=fail)
elif isinstance(value, list):
return self._transform_list(value, doc, fail=fail)
- 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 documents
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def documents(self, *sources):
q = DocumentModel.objects.timeout(500).allow_filtering().all().limit(100)
querysets = (q.filter(source=source) for source in sources) if sources else [q]
for query in querysets:
page = try_n_times(5, list, query)
- 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 copy_to_unicode
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def copy_to_unicode(element):
""" used to transform the lxml version of unicode to a
standard version of unicode that can be pickalable -
necessary for linting """
- 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 oai_process_uris
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def oai_process_uris(*args, **kwargs):
use_doi = kwargs.get('use_doi', False)
identifiers = gather_identifiers(args)
provider_uris, object_uris = seperate_provider_object_uris(identifiers)
- 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 self._transform_string(value, doc)
Avoid too many return
statements within this function. Open
return value(doc)
Function setup
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def setup(self, force=False, sync=True):
if self._setup and not force:
return True
try:
- 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"