appirits/comable

View on GitHub

Showing 34 of 34 total issues

Method change has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def change
    reversible do |dir|
      change_table :comable_stocks do |t|
        dir.up   { t.references :variant }
        dir.down { t.remove :variant_id }

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

      def change
        create_table :comable_shipments do |t|
          t.references :order, null: false
          t.references :shipment_method, null: false
          t.integer :fee, null: false
    Severity: Minor
    Found in core/db/migrate/20150423095210_create_comable_shipments.rb and 1 other location - About 50 mins to fix
    core/db/migrate/20140817194104_create_comable_payment_methods.rb on lines 2..11

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

    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

      def change
        create_table :comable_payment_methods do |t|
          t.string :name, null: false
          t.string :payment_provider_type, null: false
          t.integer :payment_provider_kind, null: false
    core/db/migrate/20150423095210_create_comable_shipments.rb on lines 2..11

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

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

          def load_directory_tree(path, parent = nil)
            children = []
            tree = { (parent || :root) => children }
    
            Dir.foreach(path) do |entry|
    Severity: Minor
    Found in backend/app/helpers/comable/admin/themes_helper.rb - About 45 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 reset_stock_from_cart has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def reset_stock_from_cart(stock, quantity)
          cart_item = find_cart_item_by(stock)
          if quantity > 0
            return add_stock_to_cart(stock, quantity) unless cart_item
            cart_item.update_attributes(quantity: quantity)
    Severity: Minor
    Found in core/app/models/concerns/comable/cart_owner.rb - About 45 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

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

    Comable::Address.create!(
      family_name: Comable::Sample::Name.family_name,
      first_name: Comable::Sample::Name.first_name,
      zip_code: Comable::Sample::Address.zip_code,
      state_name: Comable::Sample::Address.state_name,
    Severity: Minor
    Found in sample/db/samples/addresses.rb and 1 other location - About 45 mins to fix
    sample/db/samples/addresses.rb on lines 13..21

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

    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

    Comable::Address.create!(
      family_name: Comable::Sample::Name.family_name,
      first_name: Comable::Sample::Name.first_name,
      zip_code: Comable::Sample::Address.zip_code,
      state_name: Comable::Sample::Address.state_name,
    Severity: Minor
    Found in sample/db/samples/addresses.rb and 1 other location - About 45 mins to fix
    sample/db/samples/addresses.rb on lines 2..10

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

    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

          def import
            ActiveRecord::Base.transaction do
              Comable::Stock.import_from(params[:file])
            end
            redirect_to comable.admin_stocks_path, notice: Comable.t('successful')
    Severity: Minor
    Found in backend/app/controllers/comable/admin/stocks_controller.rb and 1 other location - About 35 mins to fix
    backend/app/controllers/comable/admin/products_controller.rb on lines 61..68

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

    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

          def import
            ActiveRecord::Base.transaction do
              Comable::Product.import_from(params[:file])
            end
            redirect_to comable.admin_products_path, notice: Comable.t('successful')
    Severity: Minor
    Found in backend/app/controllers/comable/admin/products_controller.rb and 1 other location - About 35 mins to fix
    backend/app/controllers/comable/admin/stocks_controller.rb on lines 63..70

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

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

          def remove_duplicated(unit)
            duplicated = false
    
            packages.each do |package|
              next unless package.find(unit)
    Severity: Minor
    Found in core/app/models/comable/inventory/adjuster.rb - About 35 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 stock_location_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def stock_location_params
            params.require(:stock_location).permit(
              :name,
              :active,
              :default,
    Severity: Minor
    Found in backend/app/controllers/comable/admin/stock_locations_controller.rb - About 35 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

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

      {
        product: girly_coat,
        options: [name: Comable::Sample.t(:size), value: 'M'] + [name: Comable::Sample.t(:color), value: Comable::Sample.t(:navy)],
        stocks_attributes: [default_stock_attributes],
        sku: 'GIRLY-COAT-MN'
    Severity: Major
    Found in sample/db/samples/variants.rb and 5 other locations - About 25 mins to fix
    sample/db/samples/variants.rb on lines 13..18
    sample/db/samples/variants.rb on lines 19..24
    sample/db/samples/variants.rb on lines 25..30
    sample/db/samples/variants.rb on lines 31..36
    sample/db/samples/variants.rb on lines 37..42

    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 6 locations. Consider refactoring.
    Open

      {
        product: suede_dress,
        options: [name: Comable::Sample.t(:size), value: 'M'] + [name: Comable::Sample.t(:color), value: Comable::Sample.t(:navy)],
        stocks_attributes: [default_stock_attributes],
        sku: 'SUEDE-DRESS-MN'
    Severity: Major
    Found in sample/db/samples/variants.rb and 5 other locations - About 25 mins to fix
    sample/db/samples/variants.rb on lines 13..18
    sample/db/samples/variants.rb on lines 25..30
    sample/db/samples/variants.rb on lines 31..36
    sample/db/samples/variants.rb on lines 37..42
    sample/db/samples/variants.rb on lines 43..48

    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 6 locations. Consider refactoring.
    Open

      {
        product: girly_coat,
        options: [name: Comable::Sample.t(:size), value: 'S'] + [name: Comable::Sample.t(:color), value: Comable::Sample.t(:navy)],
        stocks_attributes: [default_stock_attributes],
        sku: 'GIRLY-COAT-SN'
    Severity: Major
    Found in sample/db/samples/variants.rb and 5 other locations - About 25 mins to fix
    sample/db/samples/variants.rb on lines 13..18
    sample/db/samples/variants.rb on lines 19..24
    sample/db/samples/variants.rb on lines 25..30
    sample/db/samples/variants.rb on lines 31..36
    sample/db/samples/variants.rb on lines 43..48

    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 6 locations. Consider refactoring.
    Open

      {
        product: girly_coat,
        options: [name: Comable::Sample.t(:size), value: 'S'] + [name: Comable::Sample.t(:color), value: Comable::Sample.t(:beige)],
        stocks_attributes: [default_stock_attributes],
        sku: 'GIRLY-COAT-SB'
    Severity: Major
    Found in sample/db/samples/variants.rb and 5 other locations - About 25 mins to fix
    sample/db/samples/variants.rb on lines 13..18
    sample/db/samples/variants.rb on lines 19..24
    sample/db/samples/variants.rb on lines 31..36
    sample/db/samples/variants.rb on lines 37..42
    sample/db/samples/variants.rb on lines 43..48

    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 6 locations. Consider refactoring.
    Open

      {
        product: suede_dress,
        options: [name: Comable::Sample.t(:size), value: 'S'] + [name: Comable::Sample.t(:color), value: Comable::Sample.t(:navy)],
        stocks_attributes: [default_stock_attributes],
        sku: 'SUEDE-DRESS-SN'
    Severity: Major
    Found in sample/db/samples/variants.rb and 5 other locations - About 25 mins to fix
    sample/db/samples/variants.rb on lines 19..24
    sample/db/samples/variants.rb on lines 25..30
    sample/db/samples/variants.rb on lines 31..36
    sample/db/samples/variants.rb on lines 37..42
    sample/db/samples/variants.rb on lines 43..48

    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 6 locations. Consider refactoring.
    Open

      {
        product: girly_coat,
        options: [name: Comable::Sample.t(:size), value: 'M'] + [name: Comable::Sample.t(:color), value: Comable::Sample.t(:beige)],
        stocks_attributes: [default_stock_attributes],
        sku: 'GIRLY-COAT-MB'
    Severity: Major
    Found in sample/db/samples/variants.rb and 5 other locations - About 25 mins to fix
    sample/db/samples/variants.rb on lines 13..18
    sample/db/samples/variants.rb on lines 19..24
    sample/db/samples/variants.rb on lines 25..30
    sample/db/samples/variants.rb on lines 37..42
    sample/db/samples/variants.rb on lines 43..48

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

        def show
          if Rails::VERSION::MAJOR == 3
            @page = Comable::Page.find(params[:id])
          else
            @page = Comable::Page.friendly.find(params[:id])
    Severity: Minor
    Found in frontend/app/controllers/comable/pages_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 find_cart_item has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_cart_item
          cart_item = Comable::Stock.find_by(id: params[:stock_id])
          cart_item ||= Comable::Variant.find_by(id: params[:variant_id])
          cart_item ||= Comable::Product.find_by(id: params[:product_id])
          return unless cart_item
    Severity: Minor
    Found in frontend/app/controllers/comable/carts_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 __association__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def __association__(hash)
        return unless hash.is_a? Hash
    
        association = hash.keys.first
        method_path = hash_to_method_path(hash)
    Severity: Minor
    Found in core/lib/comma_extractor_extentions.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