Showing 151 of 336 total issues
Function render
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const {children} = this.props;
const {open} = this.state;
const {options, URL, gettext} = this.context;
Function search
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
search({params, lang}, res) {
// Query for the records in Elasticsearch
const Record = record(params.type);
Record.search(
{
Function updateSimilarity
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateSimilarity(callback) {
const Image = models("Image");
const file = this.getFilePath();
Function processImage
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
processImage(sourceFile, baseDir, callback) {
let hash;
let imageFile;
const existsError = new Error("Already exists.");
Function schema
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
schema(Schema) {
const DimensionSchema = new Schema({
// An ID for the dimension, computed from the original +
// width/height properties before validation.
_id: String,
Function exports
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = app => {
const User = models("User");
// serialize sessions
passport.serializeUser((user, callback) => callback(null, user._id));
Function breadcrumbs
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
breadcrumbs(value, i18n) {
const breadcrumbs = [];
if (value.heightMin || value.heightMax) {
const title = this.options.heightTitle(i18n);
Function updateSimilarity
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateSimilarity(callback) {
models("Image").findOne(
{
needsSimilarUpdate: true,
},
Function TypeView
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
const TypeView = ({
value,
url,
typeSchema,
}: {
- 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 updateImageSimilarity
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
updateImageSimilarity() {
const Image = models("Image");
const next = () => setTimeout(update, QUERY_RATE);
const update = () =>
Image.indexSimilarity((err, success) => {
- 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 addResult
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
addResult(file, callback) {
/* istanbul ignore if */
if (config.NODE_ENV !== "test") {
console.log("Adding Image:", path.basename(file));
}
Function engine
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
const engine = (filePath: string, options: Object, callback: Function) => {
const urls = urlsLib(options.options);
const viewName = path.basename(filePath, ".js");
const View = require(filePath);
Function advance
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
advance(callback) {
const state = this.getCurState();
const nextState = this.getNextState();
if (!this.canAdvance()) {
Function exports
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = (args, callback) => {
async.eachLimit(
Object.keys(options.types),
1,
(type, callback) => {
Function EditRecord
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
const EditRecord = (props: Props) => {
const {record, mode, title} = props;
const postURL = record
? record._id
? record.getEditURL
Function getFacets
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
getFacets(i18n, callback) {
const {lang} = i18n;
if (!this.facetCache) {
this.facetCache = {};
Function exports
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = app => {
const Source = models("Source");
return {
index({i18n, user}, res) {
Function uploadZipFile
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
uploadZipFile(req, res, next) {
const {source, i18n, lang} = req;
const form = new formidable.IncomingForm();
form.encoding = "utf-8";
Function facet
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
facet() {
return {
[this.options.name]: {
title: i18n => this.options.title(i18n),
- 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 addValue
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
addValue(addedValue: string, addedLabel: string) {
const {onChange, value} = this.props;
if ((!value || Array.isArray(value)) && onChange) {
this.labelCache[addedValue] = addedLabel;
onChange(
- 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"