Showing 2,584 of 2,584 total issues
File instrument.rb
has 290 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Importers::XML::DDI
class Instrument < DdiImporterBase
def initialize(thing, options = {})
if thing.is_a? String
@doc = open(thing) { |f| Nokogiri::XML(f) }
- Create a ticketCreate a ticket
Identical blocks of code found in 2 locations. Consider refactoring. Open
{!dataLoaded
? <Loader />
: <SequenceItem instrumentId={instrumentId} type={'CcSequence'} id={sequence.children[0].id} title={sequence.children[0].label} children={sequence.children[0].children}/>
}
- Read upRead up
- Create a ticketCreate a ticket
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 94.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
{!dataLoaded
? <Loader />
: <SequenceItem instrumentId={instrumentId} type={'CcSequence'} id={sequence.children[0].id} title={sequence.children[0].label} children={sequence.children[0].children}/>
}
- Read upRead up
- Create a ticketCreate a ticket
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 94.
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
Cyclomatic complexity for safe_params is too high. [17/6] Open
def safe_params
# The params from Angular use :codes in the params array, we
# tranform these into params that comply with the params expected
# by nested attributes using accepts_nested_attributes for the codes
# and their nested categories.
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Function buildInstrumentBreadcrumbs
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
const buildInstrumentBreadcrumbs = () => {
const paramsFromPath = () => {
const capturingRegex = `/instruments\\/${instrumentId}\\/(?<type>build|map)\/?(?<subtype>question_grids|question_items|response_domains|code_lists|constructs)?\/?`;
const found = location.pathname.match(new RegExp(capturingRegex));
return get(found, 'groups',{})
- Create a ticketCreate a ticket
Function UserForm
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const UserForm = (props) => {
const {user, onChange, path, onDelete} = props;
const dispatch = useDispatch();
const classes = useStyles();
- Create a ticketCreate a ticket
Function AdminUserForm
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const AdminUserForm = (props) => {
const {user} = props;
const dispatch = useDispatch();
const classes = useStyles();
- Create a ticketCreate a ticket
Function ResponseDomainDatetimeForm
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const ResponseDomainDatetimeForm = (props) => {
const {responseDomain, instrumentId, instrument} = props;
const dispatch = useDispatch();
const classes = useStyles();
- Create a ticketCreate a ticket
Method V3_2
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def V3_2(qgrid_id)
@klass = ::QuestionGrid
super do |qgrid, qg|
- Read upRead up
- Create a ticketCreate a ticket
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
Method import
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def import(options = {})
variable_ids_to_delete = @object.variables.pluck(:id)
set_import_to_running
vars = @object.variables.includes(:questions, :src_variables, :der_variables, :topic)
@doc.each do |dataset, v, t|
- Read upRead up
- Create a ticketCreate a ticket
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
File Dashboard.js
has 287 lines of code (exceeds 250 allowed). Consider refactoring. Open
import React, { useEffect } from 'react';
import { useSelector } from 'react-redux'
import { get } from 'lodash'
import clsx from 'clsx';
import { makeStyles } from '@material-ui/core/styles';
- Create a ticketCreate a ticket
Function QuestionGridListItem
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
const QuestionGridListItem = (props) => {
const { item, instrumentId } = props
const classes = useStyles();
const title = (isEmpty(item.question)) ? item.label : item.question.literal
- Create a ticketCreate a ticket
Function AdminInstrumentForm
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const AdminInstrumentForm = (props) => {
const {instrument, datasets} = props;
const [signedOff, setSignedOff] = React.useState(instrument.signed_off);
- Create a ticketCreate a ticket
Method has too many lines. [40/30] Open
def safe_params
# The params from Angular use :codes in the params array, we
# tranform these into params that comply with the params expected
# by nested attributes using accepts_nested_attributes for the codes
# and their nested categories.
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [40/30] Open
def import(options = {})
variable_ids_to_delete = @object.variables.pluck(:id)
set_import_to_running
vars = @object.variables.includes(:questions, :src_variables, :der_variables, :topic)
@doc.each do |dataset, v, t|
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Function DatasetView
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
const DatasetView = (props) => {
const { dataset } = props;
const classes = useStyles();
- Create a ticketCreate a ticket
Similar blocks of code found in 3 locations. Consider refactoring. Open
case 'CcSequence':
return (
<StyledListItem className={classes.nested}>
<SequenceItem instrumentId={instrumentId} id={child.id} type={child.type} title={child.type} children={get(child,'children',[])} />
</StyledListItem>)
- Read upRead up
- Create a ticketCreate a ticket
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 91.
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 3 locations. Consider refactoring. Open
case 'CcSequence':
return (
<StyledListItem className={classes.nested}>
<SequenceItem instrumentId={instrumentId} id={child.id} type={child.type} title={child.type} children={get(child,'children',[])} />
</StyledListItem>)
- Read upRead up
- Create a ticketCreate a ticket
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 91.
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 3 locations. Consider refactoring. Open
case 'CcSequence':
return (
<ListItem className={classes.nested}>
<SequenceItem instrumentId={instrumentId} id={child.id} type={child.type} title={child.type} children={get(child, 'children', [])} />
</ListItem>)
- Read upRead up
- Create a ticketCreate a ticket
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 91.
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 ConfirmationModal
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const ConfirmationModal = (props) => {
const { textToConfirm="", key="prefix", objectType="instrument", onConfirm=()=>{} } = props;
const classes = useStyles();
// getModalStyle is not a pure function, we roll the style only on the first render
const [modalStyle] = React.useState(getModalStyle);
- Create a ticketCreate a ticket