mongaku/mongaku

View on GitHub

Showing 151 of 336 total issues

Function fromData has 96 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    fromData(tmpData, i18n, callback) {
        const Record = recordModel(this.getType());
        const Image = models("Image");

        const {error, warnings, data} = this.lintData(tmpData, i18n);
Severity: Major
Found in src/schemas/Record.js - About 3 hrs to fix

    Function addSources has 92 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            addSources(req, res, next) {
                const {i18n, lang} = req;
                const {isPrivate, type, converter, sources} = req.body;
    
                let createdOrUpdated = 0;
    Severity: Major
    Found in src/logic/admin.js - About 3 hrs to fix

      Function renderMenu has 85 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          renderMenu() {
              const {create} = this.props;
              const {searchValue, options, error} = this.state;
              const {gettext, format} = this.context;
      
      
      Severity: Major
      Found in src/views/shared/Select.js - About 3 hrs to fix

        Function addUsers has 85 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                addUsers(req, res, next) {
                    const {lang, i18n} = req;
        
                    let createdOrUpdated = 0;
                    const failed = [];
        Severity: Major
        Found in src/logic/admin.js - About 3 hrs to fix

          Function exports has 82 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = type => {
              if (records[type]) {
                  return records[type];
              }
          
          
          Severity: Major
          Found in src/lib/record.js - About 3 hrs to fix

            Function exports has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports = (options: Options) => {
                const genURL = (lang: ?string, urlBase: string, origPath: string) => {
                    let suffix = "";
                    let base = urlBase;
                    let path = origPath;
            Severity: Minor
            Found in src/lib/urls.js - About 3 hrs to fix

            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 exports has 81 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function(app) {
                return {
                    index({lang}, res) {
                        const sitemaps = [];
            
            
            Severity: Major
            Found in src/logic/sitemaps.js - About 3 hrs to fix

              Function clusterImages has 81 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const clusterImages = (records: Array<RecordType>) => {
                  const sourceRecord = records[0];
                  const rows = [
                      {
                          record: sourceRecord,
              Severity: Major
              Found in src/views/Record.js - About 3 hrs to fix

                File RecordImport.js has 301 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                const async = require("async");
                
                const record = require("../lib/record");
                const models = require("../lib/models");
                const db = require("../lib/db");
                Severity: Minor
                Found in src/schemas/RecordImport.js - About 3 hrs to fix

                  File Page.js has 294 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  // @flow
                  
                  const React = require("react");
                  
                  import type {Context} from "./types.js";
                  Severity: Minor
                  Found in src/views/Page.js - About 3 hrs to fix

                    File SearchForm.js has 288 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    // @flow
                    
                    const React = require("react");
                    
                    const Select = require("./shared/Select.js");
                    Severity: Minor
                    Found in src/views/SearchForm.js - About 2 hrs to fix

                      File express_v4.x.x.js has 286 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      // NOTE(jeresig): This is a modified version of the Express flow types
                      // from flow-typed, modified to include the custom properties on the
                      // request object. Theoretically it should be possible to extend this
                      // according to this diff, but I can't figure it out:
                      // https://github.com/flowtype/flow-typed/pull/508
                      Severity: Minor
                      Found in types/express_v4.x.x.js - About 2 hrs to fix

                        Function filter has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            filter(value) {
                                // NOTE(jeresig): There has got to be a better way to handle this.
                                const start = value.start || -10000;
                                const end = value.end || new Date().getYear() + 1900;
                        
                        
                        Severity: Major
                        Found in src/schemas/types/YearRange.js - About 2 hrs to fix

                          Function paramFilter has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const paramFilter = (values, keepSecondary) => {
                              const all = {};
                              const primary = [];
                              const secondary = {};
                              const type = values.type || Object.keys(options.types)[0];
                          Severity: Minor
                          Found in src/logic/shared/param-filter.js - About 2 hrs to fix

                          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 render has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              render() {
                                  const {mode, type, globalFacets, dynamicValues} = this.props;
                                  const {gettext, options} = this.context;
                                  const {model} = options.types[type];
                                  const types = Object.keys(model);
                          Severity: Major
                          Found in src/views/EditRecord.js - About 2 hrs to fix

                            File Dimension.js has 268 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            const pd = require("parse-dimensions");
                            
                            const numRange = bucket =>
                                bucket.to
                                    ? `${bucket.from || 0}-${bucket.to}${bucket.unit}`
                            Severity: Minor
                            Found in src/schemas/types/Dimension.js - About 2 hrs to fix

                              Function updateSimilarity has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  updateSimilarity(callback) {
                                      this.getImages((err, images) => {
                                          /* istanbul ignore if */
                                          if (err) {
                                              return callback(err);
                              Severity: Major
                              Found in src/schemas/Record.js - About 2 hrs to fix

                                Function facet has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    facet() {
                                        const defaultUnit = this.defaultUnit;
                                        const unit = this.defaultSearchUnit || this.defaultUnit;
                                
                                        const formatFacetBucket = bucket => {
                                Severity: Major
                                Found in src/schemas/types/Dimension.js - About 2 hrs to fix

                                  Function importRecords has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      importRecords(callback) {
                                          const Record = record(this.type);
                                          const Source = models("Source");
                                  
                                          async.eachLimit(
                                  Severity: Major
                                  Found in src/schemas/RecordImport.js - About 2 hrs to fix

                                    Function processRecords has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        processRecords(callback) {
                                            const Record = record(this.type);
                                            const incomingIDs = {};
                                    
                                            const results = this.results;
                                    Severity: Major
                                    Found in src/schemas/RecordImport.js - About 2 hrs to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language