CartoDB/cartodb20

View on GitHub
services/datasources/lib/datasources/url/mailchimp.rb

Summary

Maintainability
C
1 day
Test Coverage

Class MailChimp has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

      class MailChimp < BaseOAuth

        # Required for all datasources
        DATASOURCE_NAME = 'mailchimp'

Severity: Minor
Found in services/datasources/lib/datasources/url/mailchimp.rb - About 2 hrs to fix

    Method validate_callback has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

            def validate_callback(params)
              code = params.fetch('code')
              if code.nil? || code == ''
                raise "Empty callback code"
              end
    Severity: Minor
    Found in services/datasources/lib/datasources/url/mailchimp.rb - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method get_resources_list has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

            def get_resources_list(filter=[])
              raise UninitializedError.new('No API client instantiated', DATASOURCE_NAME) unless @api_client.present?
    
              all_results = []
              offset = 0
    Severity: Minor
    Found in services/datasources/lib/datasources/url/mailchimp.rb - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method validate_callback has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def validate_callback(params)
              code = params.fetch('code')
              if code.nil? || code == ''
                raise "Empty callback code"
              end
    Severity: Minor
    Found in services/datasources/lib/datasources/url/mailchimp.rb - About 1 hr to fix

      Method get_resource_metadata has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

              def get_resource_metadata(id)
                raise UninitializedError.new('No API client instantiated', DATASOURCE_NAME) unless @api_client.present?
      
                item_data = {}
      
      
      Severity: Minor
      Found in services/datasources/lib/datasources/url/mailchimp.rb - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method get_resources_list has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def get_resources_list(filter=[])
                raise UninitializedError.new('No API client instantiated', DATASOURCE_NAME) unless @api_client.present?
      
                all_results = []
                offset = 0
      Severity: Minor
      Found in services/datasources/lib/datasources/url/mailchimp.rb - About 1 hr to fix

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

                def store_subscriber_if_opened(input_fields='[]', subscribers)
                  contents = ::JSON.parse(input_fields)
                  contents.each { |subject, actions|
                    unless actions.length == 0
                      actions.each { |action|
        Severity: Minor
        Found in services/datasources/lib/datasources/url/mailchimp.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

        There are no issues that match your filters.

        Category
        Status