KentaaNL/tikkie-api

View on GitHub

Showing 13 of 13 total issues

Method request has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def request(http_method, path, params = {}, body = {})
        uri = URI.join(config.api_url, path)
        uri.query = URI.encode_www_form(params) unless params.empty?

        logger.debug("[Tikkie] Request: #{http_method.upcase} #{uri}") if ENV['TIKKIE_DEBUG']
Severity: Minor
Found in lib/tikkie/api/request.rb - About 1 hr to fix

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

              def list(platform_token, user_token, options = {})
                offset = options[:offset] || 0
                limit = options[:limit] || 20
                from_date = options[:from_date]
                to_date = options[:to_date]
    Severity: Minor
    Found in lib/tikkie/api/v1/requests/payment_requests.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 request has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def request(http_method, path, params = {}, body = {})
            uri = URI.join(config.api_url, path)
            uri.query = URI.encode_www_form(params) unless params.empty?
    
            logger.debug("[Tikkie] Request: #{http_method.upcase} #{uri}") if ENV['TIKKIE_DEBUG']
    Severity: Minor
    Found in lib/tikkie/api/request.rb - About 55 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 load_resource has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            def load_resource
              params = { pageNumber: page_number, pageSize: page_size }
              params[:fromDate] = options[:from_date].respond_to?(:utc) ? options[:from_date].utc.iso8601 : options[:from_date] if options.key?(:from_date)
              params[:toDate] = options[:to_date].respond_to?(:utc) ? options[:to_date].utc.iso8601 : options[:to_date] if options.key?(:to_date)
              params[:includeRefunds] = options[:include_refunds] if options.key?(:include_refunds)
    Severity: Minor
    Found in lib/tikkie/api/resources/payments.rb - About 55 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 load_resource has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def load_resource
              params = { pageNumber: page_number, pageSize: page_size }
              params[:fromDate] = options[:from_date].respond_to?(:utc) ? options[:from_date].utc.iso8601 : options[:from_date] if options.key?(:from_date)
              params[:toDate] = options[:to_date].respond_to?(:utc) ? options[:to_date].utc.iso8601 : options[:to_date] if options.key?(:to_date)
    
    
    Severity: Minor
    Found in lib/tikkie/api/resources/payment_requests.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

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

            def refunds
              @refunds ||= begin
                refunds = []
    
                if body[:refunds]
    Severity: Minor
    Found in lib/tikkie/api/resources/payment.rb and 2 other locations - About 25 mins to fix
    lib/tikkie/api/resources/payment_requests.rb on lines 24..36
    lib/tikkie/api/resources/payments.rb on lines 32..44

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

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

            def payment_requests
              @payment_requests ||= begin
                payment_requests = []
    
                if body[:paymentRequests]
    Severity: Minor
    Found in lib/tikkie/api/resources/payment_requests.rb and 2 other locations - About 25 mins to fix
    lib/tikkie/api/resources/payment.rb on lines 46..58
    lib/tikkie/api/resources/payments.rb on lines 32..44

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

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

            def create_resource(attributes)
              params = { description: attributes.fetch(:description) }
              if attributes.key?(:amount)
                amount = Tikkie::Api::Amount.new(attributes[:amount])
                params[:amountInCents] = amount.to_cents
    Severity: Minor
    Found in lib/tikkie/api/resources/payment_request.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

            def payments
              @payments ||= begin
                payments = []
    
                if body[:payments]
    Severity: Minor
    Found in lib/tikkie/api/resources/payments.rb and 2 other locations - About 25 mins to fix
    lib/tikkie/api/resources/payment.rb on lines 46..58
    lib/tikkie/api/resources/payment_requests.rb on lines 24..36

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

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

              def errors
                @errors ||= begin
                  errors = []
    
                  if data[:errors]
    Severity: Minor
    Found in lib/tikkie/api/v1/responses/base.rb and 3 other locations - About 20 mins to fix
    lib/tikkie/api/v1/responses/payment_request.rb on lines 51..63
    lib/tikkie/api/v1/responses/payment_requests.rb on lines 27..39
    lib/tikkie/api/v1/responses/user.rb on lines 26..38

    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

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

              def payment_requests
                @payment_requests ||= begin
                  payment_requests = []
    
                  if data[:paymentRequests]
    Severity: Minor
    Found in lib/tikkie/api/v1/responses/payment_requests.rb and 3 other locations - About 20 mins to fix
    lib/tikkie/api/v1/responses/base.rb on lines 38..50
    lib/tikkie/api/v1/responses/payment_request.rb on lines 51..63
    lib/tikkie/api/v1/responses/user.rb on lines 26..38

    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

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

              def payments
                @payments ||= begin
                  payments = []
    
                  if data[:payments]
    Severity: Minor
    Found in lib/tikkie/api/v1/responses/payment_request.rb and 3 other locations - About 20 mins to fix
    lib/tikkie/api/v1/responses/base.rb on lines 38..50
    lib/tikkie/api/v1/responses/payment_requests.rb on lines 27..39
    lib/tikkie/api/v1/responses/user.rb on lines 26..38

    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

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

              def bank_accounts
                @bank_accounts ||= begin
                  bank_accounts = []
    
                  if data[:bankAccounts]
    Severity: Minor
    Found in lib/tikkie/api/v1/responses/user.rb and 3 other locations - About 20 mins to fix
    lib/tikkie/api/v1/responses/base.rb on lines 38..50
    lib/tikkie/api/v1/responses/payment_request.rb on lines 51..63
    lib/tikkie/api/v1/responses/payment_requests.rb on lines 27..39

    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