Showing 35 of 35 total issues
File helpers.js
has 499 lines of code (exceeds 250 allowed). Consider refactoring. Open
const _ = require('lodash');
const moment = require('moment');
const config = require('collections-online/lib/config');
const helpers = require('collections-online/shared/helpers');
Function exports
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(done) {
var pages = [
new Page.model({
title: 'Om os',
slug: 'om-os',
Function determinePlayers
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
helpers.determinePlayers = metadata => {
const players = [];
// Get at list of related assets and filter out any without an id
const relatedAssets = (
(metadata.related && metadata.related.assets) || []
File natmus-api.js
has 282 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
const assert = require('assert');
const querystring = require('querystring');
const Q = require('q');
Function determinePlayers
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
helpers.determinePlayers = metadata => {
const players = [];
// Get at list of related assets and filter out any without an id
const relatedAssets = (
(metadata.related && metadata.related.assets) || []
- 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 typeaheadSuggestions
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.typeaheadSuggestions = (text) => {
const ds = require('collections-online/lib/services/documents');
return ds.search({
'size': 0,
'body': {
Similar blocks of code found in 2 locations. Consider refactoring. Open
hits.forEach((hit) => {
// Insert
actions.push({
index: {
_index: toIndex,
- 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 79.
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
hits.forEach((hit) => {
// Insert
actions.push({
index: {
_index: index,
- 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 79.
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 run
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
function run(esHost, fromIndex, toIndex) {
console.log('Hello from es-indexing');
var es = new elasticsearch.Client({
host: esHost,
Similar blocks of code found in 2 locations. Consider refactoring. Open
removeTag: (metadata, tag) => {
// Is it there?
const tagIndex = metadata.tags.crowd.indexOf(tag);
if(tagIndex > -1) {
// Remove it
- 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 72.
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
removeVisionTag: (metadata, tag) => {
// Is it there?
const tagIndex = metadata.tags.automated.indexOf(tag);
if(tagIndex > -1) {
// Remove it
- 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 72.
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 mget
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
mget: (options) => {
if(!options.type) {
throw new Error('Expected a "type"');
}
if(!options.body || !options.body.ids) {
Function getMoreUntilDone
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
}, function getMoreUntilDone(error, response) {
if(error) {
console.error(error);
}
// collect the title from each response
Function exports
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(done) {
var as = new GalleryItem.model({
title: 'Antiksamlingen',
description: '...',
link: '/?collection=AS'
Function getObject
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getObject(req) {
let deferred = Q.defer();
let id = req.params.id;
let collection = req.params.collection;
Function getSource
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
getSource: (options) => {
if(options.index) {
console.warn('Calling the document service with index is not supported');
}
let type = options.type;
Function transformAndInsert
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function transformAndInsert(hits, index) {
// collect the title from each response
return Q.all(hits.map(function (hit) {
return TRANSFORMATIONS.reduce(Q.when, hit.data).then((metadata) => {
let type = (hit.meta.type || '').toLowerCase();
Function generateSitemapElements
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
helpers.generateSitemapElements = (req, metadata) => {
const title = helpers.documentTitle(metadata);
const description = helpers.documentDescription(metadata);
const relativeThumbnailUrl = helpers.getThumbnailURL(metadata);
const thumbnailUrl = helpers.getAbsoluteURL(req, relativeThumbnailUrl);
Function pollForChange
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
pollForChange: (type, collectionAndId) => {
const key = type + '/' + collectionAndId;
// Start polling the index for changes, based on the meta.modified field
const startedPolling = new Date();
let interval;
Function AVAILABLE_DOWNLOAD_OPTIONS
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
.map(optionKey => {
const option = config.downloadOptions[optionKey];
if(option.size) {
return generateSizeDownloadOption(optionKey, option);