indentlabs/notebook

View on GitHub

Showing 288 of 288 total issues

Avoid too many return statements within this method.
Open

    return true if ::PermissionService.content_is_in_a_public_universe?(content: resource)
Severity: Major
Found in app/authorizers/content_authorizer.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

        return true if user && resource.universe.present? && resource.universe.user_id == user.id
    Severity: Major
    Found in app/authorizers/document_authorizer.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

          return false
      Severity: Major
      Found in app/services/permission_service.rb - About 30 mins to fix

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

                    <FormControlLabel
                      value="private"
                      control={<Radio color="primary" />}
                      label="Private (default)"
                      labelPlacement="start"
        Severity: Minor
        Found in app/javascript/components/PrivacyToggle.js and 1 other location - About 30 mins to fix
        app/javascript/components/PrivacyToggle.js on lines 88..94

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

        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

        Avoid too many return statements within this method.
        Open

              return # hurrah!
        Severity: Major
        Found in app/services/temporary_field_migration_service.rb - About 30 mins to fix

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

                      <FormControlLabel
                        value="public"
                        control={<Radio color="primary" />}
                        label="Public"
                        labelPlacement="start"
          Severity: Minor
          Found in app/javascript/components/PrivacyToggle.js and 1 other location - About 30 mins to fix
          app/javascript/components/PrivacyToggle.js on lines 80..87

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

          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

          Avoid too many return statements within this method.
          Open

                  return 'red'
          Severity: Major
          Found in app/services/emotion_service.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                return if !!content_model.columns_migrated_from_old_style?
            Severity: Major
            Found in app/services/temporary_field_migration_service.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return 'white'
              Severity: Major
              Found in app/services/emotion_service.rb - About 30 mins to fix

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

                    word_count = WordCountAnalyzer::Counter.new(
                      ellipsis:          'no_special_treatment',
                      hyperlink:         'count_as_one',
                      contraction:       'count_as_one',
                      hyphenated_word:   'count_as_one',
                Severity: Minor
                Found in app/jobs/cache_attribute_word_count_job.rb and 1 other location - About 30 mins to fix
                app/models/documents/document.rb on lines 106..121

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

                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

                    WordCountAnalyzer::Counter.new(
                      ellipsis:          'no_special_treatment',
                      hyperlink:         'count_as_one',
                      contraction:       'count_as_one',
                      hyphenated_word:   'count_as_one',
                Severity: Minor
                Found in app/models/documents/document.rb and 1 other location - About 30 mins to fix
                app/jobs/cache_attribute_word_count_job.rb on lines 15..30

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

                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

                      message_html:     "<div>An analysis of <span class='#{Document.text_color}'>#{analysis.document.title}</span> is ready to view.</div>",
                      icon:             Document.icon,
                      icon_color:       Document.color,
                      happened_at:      DateTime.current,
                      passthrough_link: Rails.application.routes.url_helpers.analysis_document_url(analysis.document),
                Severity: Minor
                Found in app/jobs/document_analysis_job.rb and 1 other location - About 25 mins to fix
                app/controllers/registrations_controller.rb on lines 87..93

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

                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

                            message_html:     "<div>You have been added as a contributor to the <span class='#{Universe.text_color}'>#{contributorship.universe.name}</span> universe.</div>",
                            icon:             Universe.icon,
                            icon_color:       Universe.color,
                            happened_at:      DateTime.current,
                            passthrough_link: Rails.application.routes.url_helpers.universe_path(contributorship.universe),
                Severity: Minor
                Found in app/controllers/registrations_controller.rb and 1 other location - About 25 mins to fix
                app/jobs/document_analysis_job.rb on lines 41..47

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

                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 name_field_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def name_field_value
                      @name_field_lookup_cache ||= {}
                      cache_key = "#{self.class.name}-#{self.id.to_s}"
                
                      if @name_field_lookup_cache.key?(cache_key)
                Severity: Minor
                Found in app/models/concerns/has_attributes.rb - About 25 mins 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 cache_current_user_content has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def cache_current_user_content
                    return if @current_user_content
                
                    @current_user_content = {}
                    return unless user_signed_in?
                Severity: Minor
                Found in app/controllers/application_controller.rb - About 25 mins 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 babel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def babel
                    EasyTranslate.api_key = ENV['GOOGLE_TRANSLATE_API_KEY']
                
                    @translations = [["afrikaans", "amarach"], ["albanian", "amarach"], ["arabic", "amarach"], ["belarusian", "amarach"], ["bulgarian", "amarach"], ["catalan", "Amarachi"], ["chinese_simplified", "amarach"], ["chinese_traditional", "amarach"], ["croatian", "Amarachi"], ["czech", "Amarachi"], ["danish", "Amarach"], ["dutch", "Amarach"], ["estonian", "Amarachi"], ["filipino", "Amarach"], ["finnish", "Amarachi"], ["french", "Amarach"], ["galician", "Amarachi"], ["german", "Amarach"], ["greek", "amarach"], ["hebrew", "amarach"], ["hindi", "Amrc"], ["hungarian", "Amarachi"], ["icelandic", "Amarachi"], ["indonesian", "Amarach"], ["irish", "tomorrow"], ["italian", "Amarach"], ["japanese", "amarach"], ["korean", "amarach"], ["latin", "amarach"], ["latvian", "Amárach"], ["lithuanian", "Amarachi"], ["macedonian", "amarach"], ["malay", "Amarach"], ["maltese", "Amárach"], ["norwegian", "Amarach"], ["persian", "amarach"], ["polish", "Amarach"], ["portuguese", "Amarach"], ["romanian", "Amarachi"], ["russian", "amarach"], ["serbian", "Amarachi"], ["slovak", "Amarach"], ["slovenian", "Amarachi"], ["spanish", "Amarach"], ["swahili", "amarach"], ["swedish", "Amarach"], ["thai", "amarach"], ["turkish", "Amarachi"], ["ukrainian", "amarach"], ["vietnamese", "amarach"], ["welsh", "amarach"], ["yiddish", "amarach"]]
                
                
                Severity: Minor
                Found in app/controllers/lab_controller.rb - About 25 mins 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 creatable_by? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def self.creatable_by? user
                    return false unless user.present?
                    return false if ENV.key?('CONTENT_BLACKLIST') && ENV['CONTENT_BLACKLIST'].split(',').include?(user.email)
                
                    return true if PermissionService.user_has_fewer_owned_universes_than_plan_limit?(user: user)
                Severity: Minor
                Found in app/authorizers/universe_core_content_authorizer.rb - About 25 mins 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 information_change has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def information_change
                    valid_token = params[:stripeToken]
                    if valid_token.nil?
                      flash[:alert] = "We couldn't validate the card information you entered. Please make sure you have Javascript enabled in your browser."
                      return redirect_back fallback_location: payment_info_path
                Severity: Minor
                Found in app/controllers/subscriptions_controller.rb - About 25 mins 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 overview_field_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def overview_field_value(label)
                      field_cache = overview_field(label)
                      return nil if field_cache.nil?
                
                      field_cache
                Severity: Minor
                Found in app/models/concerns/has_attributes.rb - About 25 mins 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 get_field_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_field_value(category, field, fallback=nil)
                      category = AttributeCategory.find_by(
                        label:       category,
                        entity_type: self.class.name.downcase,
                        user_id:     self.user_id,
                Severity: Minor
                Found in app/models/concerns/has_attributes.rb - About 25 mins 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

                Severity
                Category
                Status
                Source
                Language