lespoupeesrusses/promethee

View on GitHub

Showing 22 of 22 total issues

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

    def upgraded_attributes
      {
        'size' => {
          'searchable' => false,
          'translatable' => false,
Severity: Major
Found in app/services/promethee/structure_upgrader/components/column.rb - About 2 hrs to fix

    Method promethee_sanitize_attributes has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

      def promethee_sanitize_attributes(attributes)
        attributes.each do |key, value_object|
          case value_object['type']
          when 'string'
            while value_object['value'] != Loofah.fragment(value_object['value']).text(encode_special_chars: false)
    Severity: Minor
    Found in app/models/concerns/promethee_data.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 upgraded_backgrounds has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def upgraded_backgrounds(backgrounds)
          backgrounds ||= []
          backgrounds.map { |background|
            {
              'image' => {
    Severity: Minor
    Found in app/services/promethee/structure_upgrader/components/row.rb - About 1 hr to fix

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

        class SliderItem < Base
          def upgraded_attributes
            {
              'caption' => {
                'searchable' => true,
      app/services/promethee/structure_upgrader/components/collection_item.rb on lines 21..50

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

      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

        class CollectionItem < Base
          def upgraded_attributes
            {
              'caption' => {
                'searchable' => true,
      app/services/promethee/structure_upgrader/components/slider_item.rb on lines 21..50

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

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

          def upgraded_attributes
            {
              'title' => {
                'searchable' => true,
                'translatable' => true,
      Severity: Minor
      Found in app/services/promethee/structure_upgrader/components/page.rb - About 1 hr to fix

        Method upgraded_attributes has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def upgraded_attributes
              {
                'visible_content' => {
                  'searchable' => true,
                  'translatable' => true,
        Severity: Minor
        Found in app/services/promethee/structure_upgrader/components/aside.rb - About 1 hr to fix

          Method upgraded_attributes has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def upgraded_attributes
                {
                  'caption' => {
                    'searchable' => true,
                    'translatable' => true,

            Method upgraded_attributes has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def upgraded_attributes
                  {
                    'caption' => {
                      'searchable' => true,
                      'translatable' => true,
            Severity: Minor
            Found in app/services/promethee/structure_upgrader/components/slider_item.rb - About 1 hr to fix

              Method upgraded_attributes has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def upgraded_attributes
                    {
                      'image' => {
                        'searchable' => false,
                        'translatable' => false,
              Severity: Minor
              Found in app/services/promethee/structure_upgrader/components/faq_item.rb - About 1 hr to fix

                Method upgraded_attributes has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def upgraded_attributes
                      {
                        'image' => {
                          'searchable' => false,
                          'translatable' => false,
                Severity: Minor
                Found in app/services/promethee/structure_upgrader/components/cover.rb - About 1 hr to fix

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

                          'tablet' => {
                            'searchable' => false,
                            'translatable' => false,
                            'type' => 'hash',
                            'value' => {
                  Severity: Minor
                  Found in app/services/promethee/structure_upgrader/components/column.rb and 1 other location - About 55 mins to fix
                  app/services/promethee/structure_upgrader/components/column.rb on lines 39..60

                  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

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

                          'mobile' => {
                            'searchable' => false,
                            'translatable' => false,
                            'type' => 'hash',
                            'value' => {
                  Severity: Minor
                  Found in app/services/promethee/structure_upgrader/components/column.rb and 1 other location - About 55 mins to fix
                  app/services/promethee/structure_upgrader/components/column.rb on lines 64..85

                  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

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

                      def generate_cell_matrix_from_data
                        cols_data = attribute('cols_data').to_h
                        rows_data = attribute('rows_data').to_h
                        data_matrix = []
                  
                  
                  Severity: Minor
                  Found in app/services/promethee/structure_upgrader/components/table.rb and 1 other location - About 40 mins to fix
                  app/services/promethee/structure_upgrader/components/table.rb on lines 43..53

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 37.

                  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 generate_cell_matrix_from_structure
                        cols = attribute('cols').to_a
                        rows = attribute('rows').to_a
                        data_matrix = []
                  
                  
                  Severity: Minor
                  Found in app/services/promethee/structure_upgrader/components/table.rb and 1 other location - About 40 mins to fix
                  app/services/promethee/structure_upgrader/components/table.rb on lines 56..66

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

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

                    def promethee_extract_searchable_attributes(attributes)
                      searchable = ' '
                      attributes.each do |key, value_object|
                        if value_object['searchable']
                          clean_value = strip_tags value_object['value']
                  Severity: Minor
                  Found in app/models/concerns/promethee_data.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 blob_show has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def blob_show
                      # as this is called only from promethee preview it sends an image resized to 720
                      begin
                        blob_find_method = ActiveStorage::Blob.respond_to?(:find_signed!) ? :find_signed! : :find_signed
                        blob = ActiveStorage::Blob.public_send(blob_find_method, params[:id])
                  Severity: Minor
                  Found in app/controllers/promethee_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

                  Method blob_from_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def blob_from_data(blob_data = {})
                      return unless blob_data&.has_key? :id
                      blob_find_method = ActiveStorage::Blob.respond_to?(:find_signed!) ? :find_signed! : :find_signed
                      ActiveStorage::Blob.public_send blob_find_method, blob_data[:id]
                    rescue
                  Severity: Minor
                  Found in lib/promethee/rails/helper.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 upgrade_attribute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def upgrade_attribute(attribute_value)
                        return upgrade_blob_data(attribute_value) if is_blob_data?(attribute_value)
                  
                        if attribute_value.is_a? Array
                          attribute_value.map { |item| upgrade_attribute(item) }
                  Severity: Minor
                  Found in app/services/promethee/blob_upgrade_service.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

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

                            'posh' => {
                              'collection' => [
                                { 'label' => 'Left', 'value' => 'left' },
                                { 'label' => 'Center', 'value' => 'center' },
                                { 'label' => 'Right', 'value' => 'right' }
                  Severity: Minor
                  Found in app/services/promethee/structure_upgrader/components/row.rb and 2 other locations - About 20 mins to fix
                  app/services/promethee/structure_upgrader/components/row.rb on lines 55..64
                  app/services/promethee/structure_upgrader/components/row.rb on lines 66..75

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

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language