mongaku/mongaku

View on GitHub

Showing 151 of 336 total issues

Function fromFile has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    fromFile(batch, file, callback) {
        const Image = models("Image");
        const Source = models("Source");

        const filePath = file.path || file;
Severity: Major
Found in src/schemas/Image.js - About 2 hrs to fix

    Function TypeFilter has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    const TypeFilter = ({
        name,
        value,
        allValues,
        typeSchema,
    Severity: Minor
    Found in src/views/SearchForm.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 exports has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = (
        lang: string,
        options: Options,
        translations: {
            [message: string]: ?Array<string>,
    Severity: Minor
    Found in src/views/utils.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

    File ImageImport.js has 260 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const os = require("os");
    const fs = require("fs");
    const path = require("path");
    
    const glob = require("glob");
    Severity: Minor
    Found in src/schemas/ImageImport.js - About 2 hrs to fix

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

          filter(value) {
              const filters = [];
      
              if (value.widthMin) {
                  filters.push({
      Severity: Major
      Found in src/schemas/types/Dimension.js - About 2 hrs to fix

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

        module.exports = (fields, {originalUrl, i18n, user}, callback) => {
            // 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
        Severity: Minor
        Found in src/logic/shared/search.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 updateSimilarity has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            updateSimilarity(callback) {
                // Skip small images
                if (!this.canIndex()) {
                    return process.nextTick(callback);
                }
        Severity: Major
        Found in src/schemas/Image.js - About 2 hrs to fix

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

          module.exports = (
              lang: string,
              options: Options,
              translations: {
                  [message: string]: ?Array<string>,
          Severity: Major
          Found in src/views/utils.js - About 2 hrs to fix

            Function routes has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    routes() {
                        const source = (req, res, next) => {
                            const {
                                params: {source},
                            } = req;
            Severity: Minor
            Found in src/logic/source-admin.js - About 2 hrs to fix

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

              module.exports = (req, res, next, tmplParams) => {
                  const {i18n, query, params} = req;
                  const fields = Object.assign({}, query, params);
                  const {type} = params;
              
              
              Severity: Minor
              Found in src/logic/shared/search-page.js - About 1 hr to fix

                Function uploadData has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        uploadData(req, res, next) {
                            const {source, i18n, lang} = req;
                
                            const form = new formidable.IncomingForm();
                            form.encoding = "utf-8";
                Severity: Minor
                Found in src/logic/source-admin.js - About 1 hr to fix

                  Function render has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      render() {
                          const {facet} = this.props;
                          const {gettext, format} = this.context;
                          let {buckets} = facet;
                          let extra = null;
                  Severity: Minor
                  Found in src/views/Search.js - About 1 hr to fix

                    Function show has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            show({params, i18n, user}, res) {
                                // TODO: Update similar matches if new image data has
                                // since come in since it was last updated.
                                const _id = `uploads/${params.upload}`;
                                Upload.findById(_id, (err, upload) => {
                    Severity: Minor
                    Found in src/logic/uploads.js - About 1 hr to fix

                      Function advance has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          advance(callback) {
                              this.find(
                                  {
                                      state: {
                                          $nin: ["completed", "error"],
                      Severity: Minor
                      Found in src/schemas/Import.js - About 1 hr to fix

                        Function render has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            render() {
                                const {success, error} = this.props;
                                const {gettext, URL} = this.context;
                        
                                return (
                        Severity: Minor
                        Found in src/views/Admin.js - About 1 hr to fix

                          Function processZipFile has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              processZipFile(callback) {
                                  const zipFile = fs.createReadStream(this.zipFile);
                                  let zipError;
                                  const files = [];
                                  const extractDir = path.join(
                          Severity: Minor
                          Found in src/schemas/ImageImport.js - About 1 hr to fix

                            Function serializeValue has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                            Open

                            const serializeValue = (i18n: i18nObject, blacklist: Array<string> = []) => (
                                value: any,
                                key: string,
                                object: Object,
                            ) => {
                            Severity: Minor
                            Found in src/lib/clone.js - About 1 hr 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 getExpectedType has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                            Open

                            const getExpectedType = (options, value) => {
                                if (Array.isArray(options.type)) {
                                    return Array.isArray(value) ? false : "array";
                                }
                            
                            
                            Severity: Minor
                            Found in src/schemas/Record.js - About 1 hr 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 loadImages has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                loadImages(loadSimilarRecords, callback) {
                                    async.parallel(
                                        [
                                            callback => {
                                                this.getImages((err, images) => {
                            Severity: Minor
                            Found in src/schemas/Record.js - About 1 hr to fix

                              Function handleInput has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  handleInput(searchValue: string) {
                                      const {loadOptions, options} = this.props;
                              
                                      this.setState({
                                          searchValue,
                              Severity: Minor
                              Found in src/views/shared/Select.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language