Showing 44 of 44 total issues
Function multiselectAutocomplete
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
dit.components.multiselectAutocomplete = (function() {
function MultiSelectAutocomplete(options) {
var selectInputElement = options.selectInputElement;
var autocompleteId = selectInputElement.id + '_autocomplete';
- 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 lookup
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
dit.components.lookup = (new function() {
/* Performs a data lookup and displays multiple choice results
* to populate the input value with user choice.
*
- 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 CookiesModal
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function CookiesModal(props) {
let firstLink;
const [isOpen, setIsOpen] = React.useState(props.isOpen)
const focusTrap = React.useRef(false);
Function languageSelectorDropdown
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
dit.components.languageSelectorDropdown = (new function() {
var self = this;
var LANGUAGE_SELECT = '#great-header-language-select';
var LANGUAGE_SUBMIT = '#great-header-language-submit';
Function dismissableBanner
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
dit.components.dismissableBanner = (new function() {
var BANNER_ID = 'information-banner';
var BANNER_CLOSE_BUTTON_ID = 'dismiss-banner';
Function render
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def render(self, context):
html = self.nodelist.render(context)
soup = BeautifulSoup(html, 'html.parser')
selector = self.target.resolve(context)
- 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 openMenu
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
self.openMenu = function() {
$(self.MENU_BUTTON)
.addClass("expanded")
.attr("aria-expanded", "true");
$(self.MOBILE_NAV)
Function __init__
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
for name, field in self.fields.items():
if isinstance(field, RadioNested):
nested_form = field.nested_form_class(*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 data
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
dit.data = (new function() {
function Service(url, configuration) {
var service = this;
var config = $.extend({
Function handle
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **options):
client = hvac.Client(url=f"https://{options['domain']}", token=options['token'])
assert client.is_authenticated()
for path in helpers.list_vault_paths(client=client, root=options['root']):
- 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 responsive
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
dit.responsive = dit.responsive || (new function () {
// Constants
var RESET_EVENT = "dit:responsive:reset";
var RESPONSIVE_ELEMENT_ID = "dit-responsive-size";
- 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 resolve_setting_name
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def resolve_setting_name(name, settings_keys):
resolved_name = None
match = next((item for item in settings_keys if item == name), None)
# prevent matching SECRET_KEY to LIBRARY_SECRET_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 create_option
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_option(
Function __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, nodelist,
Function CookiesModal
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export function CookiesModal(props) {
let firstLink;
const [isOpen, setIsOpen] = React.useState(props.isOpen)
const focusTrap = React.useRef(false);
- 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_option
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def create_option(
self, name, value, label, selected, index,
subindex=None, attrs=None):
"""Patch to use nicer ids."""
index = str(index) if subindex is None else "%s%s%s" % (
- 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
for (var index=0; index < ctaClasses.length; index++) {
if (linkClasses.includes(ctaClasses[index])) {
return true;
}
}
- 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 49.
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
for (var index=0; index < cardClasses.length; index++) {
if (linkClasses.includes(cardClasses[index])) {
return true;
}
}
- 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 49.
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 formEvent
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function formEvent(action, type, element, value, data) {
Function linkEvent
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function linkEvent(action, type, element, value, destination) {