Showing 1,033 of 1,033 total issues
Function fetchOptions
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
async fetchOptions(query) {
if (!query) {
return {
options: []
};
- 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 collectionCreateOrEditHandler
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export async function collectionCreateOrEditHandler(req, res, next) {
try {
const {UserCollection, UserCollectionCollaborator} = req.app.locals.orm;
const isNew = !res.locals.collection;
let newCollection;
- 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 editionGroupToFormState
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function editionGroupToFormState(editionGroup) {
/** The front-end expects a language id rather than the language object. */
const aliases = editionGroup.aliasSet ?
editionGroup.aliasSet.aliases.map(({languageId, ...rest}) => ({
...rest,
- 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 crossSliceReducer
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function crossSliceReducer(state:State, action:Action) {
const {type} = action;
let intermediateState = state;
const activeEntityState = {
aliasEditor: state.get('aliasEditor'),
- 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 unflatten
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function unflatten(flattenObj) {
const result = {};
let cur;
let prop;
let parts;
- 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 displayEntity
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function displayEntity(req: PassportRequest, res: $Response) {
const {orm}: {orm?: any} = req.app.locals;
const {AchievementUnlock, EditorEntityVisits} = orm;
const {locals: resLocals}: {locals: any} = res;
const {entity}: {entity: any} = resLocals;
- 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 getBrowsedRelationships
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export async function getBrowsedRelationships(orm, locals, browsedEntityType,
getEntityInfoMethod, fetchRelated, filterRelationshipMethod) {
const {entity, relationships} = locals;
if (!relationships.length > 0) {
- 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 mapDispatchToProps
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function mapDispatchToProps(dispatch: Dispatch<Action>): DispatchProps {
return {
onAuthorCreditChange: (selectedAuthorCredit:AuthorCredit) => {
dispatch(updateAuthorCredit(selectedAuthorCredit));
},
- 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 dateObjectToISOString
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function dateObjectToISOString(value: DateObject) {
if (_.isNil(value) || isNullDate(value)) {
return null;
}
// if year is missing or not a number, return invalid date
- 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 triggerSearch
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
triggerSearch(newFrom = this.state.from, newSize = this.state.size) {
const searchParams = new URLSearchParams(this.props.querySearchParams);
searchParams.set('size', newSize);
searchParams.set('from', newFrom);
const newSearchParamsString = `?${searchParams.toString()}`;
Function render
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
return (
<div id="pageWithPagination">
<CollectionsTable
entityTypes={this.props.entityTypes}
Function testTiers
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function testTiers(orm, signal, editorId, tiers) {
const tierPromise = tiers.map(async (tier) => {
if (signal >= tier.threshold) {
try {
const achievementUnlock = await awardAchievement(orm, editorId, tier.name);
Function renderRelationship
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function renderRelationship(relationship: Relationship) {
const inputsInvalid =
!relationship.source || !relationship.target ||
!isString(get(relationship, 'type.linkPhrase'));
if (inputsInvalid) {
Function fetchAccessToken
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function fetchAccessToken(
code: string,
editorId: number,
orm: Record<string, any>
) : Promise<any> {
Function handleSubmit
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const handleSubmit = useCallback(async (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
if (!isValid()) {
setShowIncompleteFormError(true);
return;
Function transformISODateForDisplay
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function transformISODateForDisplay(ISODateString) {
if (_isNil(ISODateString)) {
return ISODateString;
}
const dateStringWithoutSign = ISODateString.slice(1);
Similar blocks of code found in 5 locations. Consider refactoring. Open
EditionGroupDisplayPage.propTypes = {
entity: PropTypes.object.isRequired,
identifierTypes: PropTypes.array,
user: PropTypes.object.isRequired,
wikipediaExtract: PropTypes.object
- 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 56.
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 5 locations. Consider refactoring. Open
EditionDisplayPage.propTypes = {
entity: PropTypes.object.isRequired,
identifierTypes: PropTypes.array,
user: PropTypes.object.isRequired,
wikipediaExtract: PropTypes.object
- 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 56.
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 5 locations. Consider refactoring. Open
PublisherDisplayPage.propTypes = {
entity: PropTypes.object.isRequired,
identifierTypes: PropTypes.array,
user: PropTypes.object.isRequired,
wikipediaExtract: PropTypes.object
- 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 56.
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 5 locations. Consider refactoring. Open
WorkDisplayPage.propTypes = {
entity: PropTypes.object.isRequired,
identifierTypes: PropTypes.array,
user: PropTypes.object.isRequired,
wikipediaExtract: PropTypes.object
- 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 56.
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