Showing 106 of 451 total issues
Function renderHeader
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
renderHeader() {
const gettext = this.props.gettext;
const URL = this.props.URL;
return <div className="navbar navbar-default navbar-static-top">
Function processImages
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
processImages(callback) {
const zipFile = fs.createReadStream(this.zipFile);
let zipError;
const files = [];
const extractDir = path.join(os.tmpdir(),
Function importArtworks
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
importArtworks(callback) {
const Artwork = models("Artwork");
const Source = models("Source");
async.eachLimit(this.results, 1, (result, callback) => {
Function renderArtwork
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
renderArtwork() {
const compare = this.props.compare;
const artworks = this.props.artworks;
const artworkWidth = this.props.similar.length > 0 ?
"col-md-9" : "col-md-12";
Function render
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const format = this.props.format;
const gettext = this.props.gettext;
const title = format(gettext("Image Import: %(fileName)s"),
Function fromFile
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
fromFile(file, callback) {
const UploadImage = models("UploadImage");
const sourceDir = getDirBase();
Function schema
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
schema(Schema) {
const YearRangeSchema = new Schema({
// An ID for the year range, computed from the original + start/end
// properties before validation.
_id: String,
Function render
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const searchName = this.props.searchName || this.props.name;
return <div className="row">
<div className="form-group col-xs-6 col-sm-12 col-lg-6">
Function searchByProps
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const searchByProps = function(root, propMap) {
const results = {};
const getByTagName = (name) => {
const node = root.get(`.//${name}`);
Function renderUploadImagesForm
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
renderUploadImagesForm() {
return <div className="panel panel-default">
<div className="panel-heading">
<h3 className="panel-title">
{this.props.gettext("Upload Images")}
Function searchByProps
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const searchByProps = function(root, propMap) {
const results = {};
const getByTagName = (name) => {
const node = root.get(`.//${name}`);
Function renderSearchForm
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
renderSearchForm() {
const similarity = this.props.queries.similar.filters;
return <form action={this.props.URL("/search")} method="GET">
<input type="hidden" name="lang" value={this.props.lang}/>
Function uploadData
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
uploadData(req, res, next) {
const source = req.source;
const form = new formidable.IncomingForm();
form.encoding = "utf-8";
Function schema
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
schema(Schema) {
const NameSchema = new Schema({
// An ID for the name, computed from the original + name properties
// before validation.
_id: String,
Function show
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
show(req, res) {
const compare = ("compare" in req.query);
const id = `${req.params.source}/${req.params.artworkName}`;
Artwork.findById(id, (err, artwork) => {
Function breadcrumb
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
breadcrumb(value, i18n) {
const breadcrumbs = [];
if (value.heightMin || value.heightMax) {
const title = this.options.heightTitle(i18n);
Function render
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const id = this.props.id;
const allResults = this.props.batch.getFilteredResults()[id];
const showAll = this.props.format(this.props.gettext(
"Show all %(count)s results..."),
Function exports
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
module.exports = (req, res, tmplParams) => {
// Collect all the values from the request to construct
// the search URL and matches later
// Generate the filters and facets which will be fed in to Elasticsearch
// to build the query filter and aggregations
- 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 paramFilter
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const paramFilter = (values, keepSecondary) => {
const all = {};
const primary = [];
const secondary = {};
Function importImages
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const importImages = (req, res) => {
const Image = models("Image");
const batchState = (batch) => batch.getCurState().name(req);
const batchError = (err) => ImageImport.getError(req, err);