r2js/r2admin

View on GitHub

Showing 1,887 of 1,887 total issues

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

Switchery.prototype.handleOnchange = function(state) {
  if (document.dispatchEvent) {
    var event = document.createEvent('HTMLEvents');
    event.initEvent('change', true, true);
    this.element.dispatchEvent(event);
Severity: Major
Found in assets/lib/switchery/dist/switchery.js and 1 other location - About 3 hrs to fix
assets/lib/switchery/switchery.js on lines 231..239

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

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

Switchery.prototype.handleOnchange = function(state) {
  if (document.dispatchEvent) {
    var event = document.createEvent('HTMLEvents');
    event.initEvent('change', true, true);
    this.element.dispatchEvent(event);
Severity: Major
Found in assets/lib/switchery/switchery.js and 1 other location - About 3 hrs to fix
assets/lib/switchery/dist/switchery.js on lines 1791..1799

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

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

const select = (el) => {
  const data = el.data();
  const { ref, display, value, qtype, placeholder } = data;
  const isMultiple = el.attr('multiple') === 'multiple';
  const { sort = display } = data;
Severity: Major
Found in assets/js/scripts/fields/relation.js - About 3 hrs to fix

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

    Switchery.prototype.bindClick = function() {
      var parent = this.element.parentNode.tagName.toLowerCase()
        , labelParent = (parent === 'label') ? false : true;
    
      this.setPosition(labelParent);
    Severity: Major
    Found in assets/lib/switchery/dist/switchery.js and 1 other location - About 3 hrs to fix
    assets/lib/switchery/switchery.js on lines 282..288

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

    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

    Switchery.prototype.bindClick = function() {
      var parent = this.element.parentNode.tagName.toLowerCase()
        , labelParent = (parent === 'label') ? false : true;
    
      this.setPosition(labelParent);
    Severity: Major
    Found in assets/lib/switchery/switchery.js and 1 other location - About 3 hrs to fix
    assets/lib/switchery/dist/switchery.js on lines 1842..1848

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

    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

    Switchery.prototype.init = function() {
      this.hide();
      this.show();
      this.setSize();
      this.setPosition();
    Severity: Major
    Found in assets/lib/switchery/dist/switchery.js and 1 other location - About 2 hrs to fix
    assets/lib/switchery/switchery.js on lines 316..324

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

    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

    Switchery.prototype.init = function() {
      this.hide();
      this.show();
      this.setSize();
      this.setPosition();
    Severity: Major
    Found in assets/lib/switchery/switchery.js and 1 other location - About 2 hrs to fix
    assets/lib/switchery/dist/switchery.js on lines 1876..1884

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

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

    module.exports = (app) => {
      const { Validate } = app.service('System');
      const mongoose = app.service('Mongoose');
      const Plugin = app.service('PluginService');
      const ObjectId = mongoose.Schema.Types.ObjectId;
    Severity: Major
    Found in example/model/test.js - About 2 hrs to fix

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

      function FastClick(layer) {
          'use strict';
          var oldOnClick, self = this;
      
      
      
      Severity: Major
      Found in assets/lib/switchery/dist/switchery.js - About 2 hrs to fix

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

        module.exports = function Admin(app, config) {
          const getConf = config || app.config('admin');
          if (!getConf) {
            return log('config not found!');
          }
        Severity: Major
        Found in index.js - About 2 hrs to fix

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

          module.exports = (app, njk) => {
            function FieldExtension() {
              this.tags = ['field'];
              this.parse = parse('field', this);
          
          
          Severity: Minor
          Found in lib/extension/field.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 object has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              object(req, res, next) {
                const { object, id: objectId } = req.params;
                const body = _.omit(req.body, _.isEmpty);
                let modelData;
          
          
          Severity: Major
          Found in lib/update.js - About 2 hrs to fix

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

            FastClick.prototype.onTouchEnd = function(event) {
                'use strict';
                var forElement, trackingClickStart, targetTagName, scrollParent, touch, targetElement = this.targetElement;
            
                if (!this.trackingClick) {
            Severity: Major
            Found in assets/lib/switchery/dist/switchery.js - About 2 hrs to fix

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

              module.exports = (app, njk) => {
                const AdminUtils = adminUtils(app);
              
                function PaginateExtension() {
                  this.tags = ['paginate'];
              Severity: Major
              Found in lib/extension/paginate.js - About 2 hrs to fix

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

                module.exports = (app, conf = {}) => {
                  const AdminUtils = adminUtils(app);
                  const { baseUrl = 'admin' } = conf;
                  const { errors } = AdminUtils;
                  const { created } = app.handler;
                Severity: Minor
                Found in lib/create.js - About 1 hr to fix

                  Function select2nested has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const select2nested = (data, valueField, displayField, isMultiple, prefix, initPrefix = '-') => {
                    let r = [];
                    let getPrefix = prefix;
                    if (!getPrefix) {
                      getPrefix = isMultiple ? '' : `${initPrefix} `;
                  Severity: Minor
                  Found in assets/js/scripts/fields/relation.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 PaginateExtension has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    function PaginateExtension() {
                      this.tags = ['paginate'];
                      this.parse = parse('paginate', this);
                  
                      this.run = (context, params = {}, q = {}, options = {}, body, errorBody, cb) => {
                  Severity: Minor
                  Found in lib/extension/paginate.js - About 1 hr to fix

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

                    module.exports = (app, conf = {}, viewsPath, router) => {
                      const env = app.get('env');
                    
                      const {
                        baseUrl = 'admin',
                    Severity: Minor
                    Found in lib/middleware.js - About 1 hr to fix

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

                      module.exports = (app, njk) => {
                        const AdminUtils = adminUtils(app);
                      
                        function ApiQueryExtension() {
                          this.tags = ['apiquery'];
                      Severity: Minor
                      Found in lib/extension/apiQuery.js - About 1 hr to fix

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

                            this.run = (context, params = {}, q = {}, options = {}, body, errorBody, cb) => {
                              const { object, querymen = {} } = context.ctx;
                              const { model, name, pageBaseUrl } = params;
                              let { page = 1, limit = 10, sort, populate = [] } = options;
                              const queryName = name || object;
                        Severity: Minor
                        Found in lib/extension/paginate.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language