jeresig/pharos-images

View on GitHub

Showing 451 of 451 total issues

File Artwork.js has 1020 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"use strict";

const tap = require("tap");

const init = require("../init");
Severity: Major
Found in tests/schemas/Artwork.js - About 2 days to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        model: {
            // The title of the artwork.
            title: {
                type: "SimpleString",
                title: (i18n) => i18n.gettext("Title"),
    Severity: Major
    Found in options.jsx and 1 other location - About 2 days to fix
    tests/options.js on lines 64..138

    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 443.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        model: {
            // The title of the artwork.
            title: {
                type: "SimpleString",
                title: (i18n) => i18n.gettext("Title"),
    Severity: Major
    Found in tests/options.js and 1 other location - About 2 days to fix
    options.jsx on lines 166..240

    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 443.

    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

    Further Reading

    File init.js has 840 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    "use strict";
    
    process.env.BASE_DATA_DIR = process.cwd();
    process.env.PASTEC_URL = "localhost:4212";
    process.env.ELASTICSEARCH_URL = "http://localhost:9200";
    Severity: Major
    Found in tests/init.js - About 2 days to fix

      Function genData has 378 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const genData = () => {
          artworkData = {
              id: "1234",
              source: "test",
              lang: "en",
      Severity: Major
      Found in tests/init.js - About 1 day to fix

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

        const types = {
            architecture: {
                name: (i18n) => i18n.gettext("Architecture"),
            },
        
        
        Severity: Major
        Found in options.jsx and 1 other location - About 1 day to fix
        tests/options.js on lines 3..51

        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 284.

        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

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

        const types = {
            architecture: {
                name: (i18n) => i18n.gettext("Architecture"),
            },
        
        
        Severity: Major
        Found in tests/options.js and 1 other location - About 1 day to fix
        options.jsx on lines 5..53

        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 284.

        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

        Further Reading

        Function bindStubs has 283 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const bindStubs = () => {
            sandbox = sinon.sandbox.create();
        
            sandbox.stub(Artwork, "findById", (id, callback) => {
                if (artworks[id]) {
        Severity: Major
        Found in tests/init.js - About 1 day to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          const LocationFilter = React.createClass({
              propTypes: {
                  name: React.PropTypes.string.isRequired,
                  placeholder: React.PropTypes.string,
                  searchName: React.PropTypes.string,
          Severity: Major
          Found in views/types/filter/Location.jsx and 1 other location - About 1 day to fix
          views/types/filter/Name.jsx on lines 5..28

          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 241.

          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

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          const NameFilter = React.createClass({
              propTypes: {
                  name: React.PropTypes.string.isRequired,
                  placeholder: React.PropTypes.string,
                  searchName: React.PropTypes.string,
          Severity: Major
          Found in views/types/filter/Name.jsx and 1 other location - About 1 day to fix
          views/types/filter/Location.jsx on lines 5..28

          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 241.

          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

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                      <div className="form-group col-xs-6 col-sm-12 col-lg-6">
                          <label htmlFor={`${searchName}.widthMin`}
                              className="control-label"
                          >
                              {this.props.widthTitle}
          Severity: Major
          Found in views/types/filter/Dimension.jsx and 2 other locations - About 1 day to fix
          views/types/filter/Dimension.jsx on lines 54..73
          views/types/filter/YearRange.jsx on lines 29..46

          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 225.

          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

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                      <div className="form-group col-xs-6 col-sm-12 col-lg-6">
                          <label htmlFor={`${searchName}.heightMin`}
                              className="control-label"
                          >
                              {this.props.heightTitle}
          Severity: Major
          Found in views/types/filter/Dimension.jsx and 2 other locations - About 1 day to fix
          views/types/filter/Dimension.jsx on lines 34..53
          views/types/filter/YearRange.jsx on lines 29..46

          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 225.

          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

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                  return <div className="form-group">
                      <label htmlFor={`${searchName}.start`} className="control-label">
                          {this.props.title}
                      </label>
                      <div className="form-inline">
          Severity: Major
          Found in views/types/filter/YearRange.jsx and 2 other locations - About 1 day to fix
          views/types/filter/Dimension.jsx on lines 34..53
          views/types/filter/Dimension.jsx on lines 54..73

          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 225.

          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

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          tap.test("processImages (advance, process.completed)", (t) => {
              const batch = init.getBatches()[2];
              t.equal(batch.getCurState().name(req), "Completed.");
              batch.advance((err) => {
                  t.error(err, "Error should be empty.");
          Severity: Major
          Found in tests/schemas/ImageImport.js and 1 other location - About 7 hrs to fix
          tests/schemas/ImageImport.js on lines 294..311

          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 194.

          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

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          tap.test("processImages (advance, completed)", (t) => {
              const batch = init.getBatches()[4];
              t.equal(batch.getCurState().name(req), "Completed.");
              batch.advance((err) => {
                  t.error(err, "Error should be empty.");
          Severity: Major
          Found in tests/schemas/ImageImport.js and 1 other location - About 7 hrs to fix
          tests/schemas/ImageImport.js on lines 275..292

          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 194.

          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

          Further Reading

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

          module.exports = function(app) {
              const ImageImport = models("ImageImport");
              const ArtworkImport = models("ArtworkImport");
          
              const importArtworks = (req, res) => {
          Severity: Major
          Found in logic/admin.js - About 7 hrs to fix

            Function lintData has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
            Open

                lintData(data, req, optionalSchema) {
                    const schema = optionalSchema || Artwork;
            
                    const cleaned = {};
                    const warnings = [];
            Severity: Minor
            Found in schemas/Artwork.js - About 7 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

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

            tap.test("uploadData: File Error", (t) => {
                adminLogin(() => {
                    const url = "http://localhost:3000/source/test/upload-data";
                    const file = "default-error.json";
                    const formData = {
            Severity: Major
            Found in tests/logic/admin.js and 4 other locations - About 7 hrs to fix
            tests/logic/admin.js on lines 242..264
            tests/logic/admin.js on lines 291..313
            tests/logic/admin.js on lines 315..337
            tests/logic/admin.js on lines 339..361

            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 179.

            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

            Further Reading

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

            tap.test("uploadImages: Corrupted Zip", (t) => {
                adminLogin(() => {
                    const url = "http://localhost:3000/source/test/upload-images";
                    const file = "corrupted.zip";
                    const formData = {
            Severity: Major
            Found in tests/logic/admin.js and 4 other locations - About 7 hrs to fix
            tests/logic/admin.js on lines 218..240
            tests/logic/admin.js on lines 242..264
            tests/logic/admin.js on lines 291..313
            tests/logic/admin.js on lines 339..361

            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 179.

            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

            Further Reading

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

            tap.test("uploadImages: Normal Zip", (t) => {
                adminLogin(() => {
                    const url = "http://localhost:3000/source/test/upload-images";
                    const file = "test.zip";
                    const formData = {
            Severity: Major
            Found in tests/logic/admin.js and 4 other locations - About 7 hrs to fix
            tests/logic/admin.js on lines 218..240
            tests/logic/admin.js on lines 242..264
            tests/logic/admin.js on lines 291..313
            tests/logic/admin.js on lines 315..337

            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 179.

            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

            Further Reading

            Severity
            Category
            Status
            Source
            Language