indentlabs/notebook

View on GitHub

Showing 288 of 288 total issues

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

module.exports = function(api) {
  var validEnv = ['development', 'test', 'production']
  var currentEnv = api.env()
  var isDevelopmentEnv = api.env('development')
  var isProductionEnv = api.env('production')
Severity: Major
Found in babel.config.js - About 3 hrs to fix

    Function _setupDropdown has 80 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        _setupDropdown() {
          this.wrapper = document.createElement('div');
          $(this.wrapper).addClass('select-wrapper ' + this.options.classes);
          this.$el.before($(this.wrapper));
          // Move actual select element into overflow hidden wrapper
    Severity: Major
    Found in app/assets/javascripts/z_select.js - About 3 hrs to fix

      Method initialize has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

        def initialize(content)
          # One query per table; lets not muck with joins yet
          # self.attribute_values = Attribute.where(entity_type: content.page_type, entity_id: content.id)
          # self.fields           = AttributeField.where(id: self.attribute_values.pluck(:attribute_field_id).uniq)
          self.categories       = content.class.attribute_categories(content.user)
      Severity: Minor
      Found in app/models/serializers/content_serializer.rb - 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

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

        $('.character_age_generator').click(function() {
          const target = $(this).closest('.row').find('input[type=text]');
          $.ajax({
            dataType: 'text',
            url:      '/generate/character/age',
      Severity: Major
      Found in app/assets/javascripts/generators.js and 1 other location - About 3 hrs to fix
      app/assets/javascripts/generators.js on lines 4..14

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

      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

        $('.character_name_generator').click(function() {
          const target = $(this).closest('.row').find('input[type=text]');
          $.ajax({
            dataType: 'text',
            url:      '/generate/character/name',
      Severity: Major
      Found in app/assets/javascripts/generators.js and 1 other location - About 3 hrs to fix
      app/assets/javascripts/generators.js on lines 17..27

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

      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 z_select.js has 289 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      (function($) {
        'use strict';
      
        let _defaults = {
          classes: '',
      Severity: Minor
      Found in app/assets/javascripts/z_select.js - About 2 hrs to fix

        Function getStepContent has 73 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          getStepContent(step) {
            switch (step) {
              case 0:
                return(
                  <div className="spaced-paragraphs">
        Severity: Major
        Found in app/javascript/components/PageCollectionCreationForm.js - About 2 hrs to fix

          Method stats has 73 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def stats
              @commissions = BasilCommission.all.with_deleted
          
              @queued = BasilCommission.where(completed_at: nil)
              @completed = BasilCommission.where.not(completed_at: nil).with_deleted
          Severity: Major
          Found in app/controllers/basil_controller.rb - About 2 hrs to fix

            Method fill_relations has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

              def fill_relations(ar_class, ar_relation)
                attribute_categories = ar_class.attribute_categories(current_user)
            
                ar_relation.map do |content|
                  content_repr = {}
            Severity: Minor
            Found in app/controllers/export_controller.rb - 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

            Method from_html has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.from_html(html, line_length = 80, from_charset = 'UTF-8')
                  return "" if html.nil?
            
                  txt = html.dup
            
            
            Severity: Minor
            Found in app/services/documents/plaintext_service.rb - 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

            Method initialize has 71 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def initialize(content)
                # One query per table; lets not muck with joins yet
                # self.attribute_values = Attribute.where(entity_type: content.page_type, entity_id: content.id)
                # self.fields           = AttributeField.where(id: self.attribute_values.pluck(:attribute_field_id).uniq)
                self.categories       = content.class.attribute_categories(content.user)
            Severity: Major
            Found in app/models/serializers/content_serializer.rb - About 2 hrs to fix

              Method to_csv has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                def to_csv ar_relation
                  # todo change this and (ALL `.build.class` to `.klass`)
                  ar_class = ar_relation.build.class
                  attribute_categories = ar_class.attribute_categories(current_user)
              
              
              Severity: Minor
              Found in app/controllers/export_controller.rb - 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

              Class DocumentsController has 24 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class DocumentsController < ApplicationController
                before_action :authenticate_user!, except: [:show, :analysis]
              
                # todo Uh, this is a hack. The CSRF token on document editor model to add entities is being rejected... for whatever reason.
                skip_before_action :verify_authenticity_token, only: [:link_entity]
              Severity: Minor
              Found in app/controllers/documents_controller.rb - About 2 hrs to fix

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

                  render () {
                    return (
                      <React.Fragment>
                        <ul id="document-entities-right" className="sidenav">
                          <li className="teal">
                Severity: Major
                Found in app/javascript/components/DocumentEntitiesSidebar.js - About 2 hrs to fix

                  File user.rb has 274 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  class User < ApplicationRecord
                    acts_as_paranoid
                  
                    # Include default devise modules. Others available are:
                    # :confirmable, :lockable, :timeoutable and :omniauthable
                  Severity: Minor
                  Found in app/models/users/user.rb - About 2 hrs to fix

                    Method attribute_categories has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def self.attribute_categories(user, show_hidden: false)
                          # TODO: this is a code smell; we should probably either be whitelisting or fixing whatever is calling
                          #       this with the wrong models
                          return [] if ['attribute_category', 'attribute_field'].include?(content_name)
                    
                    
                    Severity: Major
                    Found in app/models/concerns/has_attributes.rb - About 2 hrs to fix

                      Method from_html has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def self.from_html(html, line_length = 80, from_charset = 'UTF-8')
                            return "" if html.nil?
                      
                            txt = html.dup
                      
                      
                      Severity: Major
                      Found in app/services/documents/plaintext_service.rb - About 2 hrs to fix

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

                                  {['Inbox', 'Starred', 'Send email', 'Drafts'].map((text, index) => (
                                    <ListItem button key={text}>
                                      <ListItemIcon>{index % 2 === 0 ? <InboxIcon /> : <MailIcon />}</ListItemIcon>
                                      <ListItemText primary={text} />
                                    </ListItem>
                        Severity: Major
                        Found in app/javascript/components/QuickActionsSidebar.js and 1 other location - About 2 hrs to fix
                        app/javascript/components/QuickActionsSidebar.js on lines 168..173

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

                        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

                                  {['All mail', 'Trash', 'Spam'].map((text, index) => (
                                    <ListItem button key={text}>
                                      <ListItemIcon>{index % 2 === 0 ? <InboxIcon /> : <MailIcon />}</ListItemIcon>
                                      <ListItemText primary={text} />
                                    </ListItem>
                        Severity: Major
                        Found in app/javascript/components/QuickActionsSidebar.js and 1 other location - About 2 hrs to fix
                        app/javascript/components/QuickActionsSidebar.js on lines 159..164

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

                        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

                        Method page_stats has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def page_stats
                            @page_type = params[:page_type]
                            # TODO verify page_type is valid
                        
                            @commissions = BasilCommission.where(entity_type: @page_type)
                        Severity: Major
                        Found in app/controllers/basil_controller.rb - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language