GeoCerts/geocerts

View on GitHub

Showing 18 of 18 total issues

Method included has 113 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.included(base)
        base.class_eval do
          endpoint GeoCerts::API::ENDPOINT do

            action :orders, :url => '/orders.xml' do
Severity: Major
Found in lib/geo_certs/endpoints/orders.rb - About 4 hrs to fix

    Method xml_node_to_hash has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

            def xml_node_to_hash(node) 
              # If we are at the root of the document, start the hash 
              if node.element? 
               if node.children? 
                  result_hash = {} 
    Severity: Minor
    Found in lib/geo_certs/hash_extension.rb - About 3 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

    Class Order has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Order < ApiObject
    
        attr_accessor :approver_email,
                      :approver_confirmed_at,
                      :approver_notified_at,
    Severity: Minor
    Found in lib/geo_certs/order.rb - About 3 hrs to fix

      Method included has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def self.included(base)
              base.class_eval do
                endpoint GeoCerts::API::ENDPOINT do
                  action :query_fraud_score, :url => '/fraud_score.xml', :method => :post do
                    parameter 'fraud_score[ip]', :required => true, :as => :ip
      Severity: Minor
      Found in lib/geo_certs/endpoints/fraud_scores.rb - About 1 hr to fix

        Method included has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def self.included(base)
                base.class_eval do
                  endpoint GeoCerts::API::ENDPOINT do
                    
                    action :events, :url => '/events.xml' do
        Severity: Minor
        Found in lib/geo_certs/endpoints/events.rb - About 1 hr to fix

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

                      action :order_events, :url => '/orders/:order_id/events.xml' do
                        parameter :start_at
                        parameter :end_at
                        
                        parser Parsers::OrderParser do
          Severity: Major
          Found in lib/geo_certs/endpoints/events.rb and 1 other location - About 1 hr to fix
          lib/geo_certs/endpoints/events.rb on lines 10..24

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

          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

                      action :events, :url => '/events.xml' do
                        parameter :start_at
                        parameter :end_at
                        
                        parser Parsers::OrderParser do
          Severity: Major
          Found in lib/geo_certs/endpoints/events.rb and 1 other location - About 1 hr to fix
          lib/geo_certs/endpoints/events.rb on lines 29..43

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

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

                def self.included(base)
                  base.class_eval do
                    endpoint GeoCerts::API::ENDPOINT do
                      
                      action :certificates, :url => '/certificates.xml' do
          Severity: Minor
          Found in lib/geo_certs/endpoints/certificates.rb - About 1 hr to fix

            Method create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def create
                  parameters = {}
                  parameters[:approver_email]   = GeoCerts.escape(self.approver_email)
                  parameters[:years]            = GeoCerts.escape(self.years)
                  parameters[:licenses]         = GeoCerts.escape(self.licenses)
            Severity: Minor
            Found in lib/geo_certs/order.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 xml_node_to_hash has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def xml_node_to_hash(node) 
                      # If we are at the root of the document, start the hash 
                      if node.element? 
                       if node.children? 
                          result_hash = {} 
            Severity: Minor
            Found in lib/geo_certs/hash_extension.rb - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                                  if result_hash[child.name].is_a?(Object::Array)
                                    result_hash[child.name] << result
                                  else
                                    result_hash[child.name] = [result_hash[child.name]] << result
                                  end
              Severity: Major
              Found in lib/geo_certs/hash_extension.rb - About 45 mins to fix

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

                    def warnings=(input) # :nodoc:
                      @warnings = case input
                        when Hash
                          case input[:warning]
                          when Array
                Severity: Minor
                Found in lib/geo_certs/api_object.rb and 1 other location - About 40 mins to fix
                lib/geo_certs/api_object.rb on lines 32..40

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

                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 errors=(input) # :nodoc:
                      @errors = case input
                        when Hash
                          case input[:error]
                          when Array
                Severity: Minor
                Found in lib/geo_certs/api_object.rb and 1 other location - About 40 mins to fix
                lib/geo_certs/api_object.rb on lines 20..28

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

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

                    def validate
                      parameters = {}
                      parameters[:years]        = self.years
                      parameters[:licenses]     = self.licenses
                      parameters[:sans]         = GeoCerts.escape(self.sans) if self.sans
                Severity: Minor
                Found in lib/geo_certs/order.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 2 locations. Consider refactoring.
                Open

                      [errors_and_warnings['errors']['error']].compact.flatten.each do |error|
                        self.errors << GeoCerts::Error.new(:code => error['code'], :message => error['message'])
                Severity: Minor
                Found in lib/geo_certs/exceptions.rb and 1 other location - About 15 mins to fix
                lib/geo_certs/exceptions.rb on lines 103..104

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

                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

                      [errors_and_warnings['errors']['warning']].compact.flatten.each do |error|
                        self.warnings << GeoCerts::Warning.new(:code => error['code'], :message => error['message'])
                Severity: Minor
                Found in lib/geo_certs/exceptions.rb and 1 other location - About 15 mins to fix
                lib/geo_certs/exceptions.rb on lines 100..101

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

                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

                            action :modify_order, :url => '/orders/:id/modify.xml', :method => :put do
                              parameter 'order[state]', :as => :state, :required => true
                              parser Parsers::OrderParser do
                                element :order do
                                  eval(ELEMENTS)
                Severity: Minor
                Found in lib/geo_certs/endpoints/orders.rb and 1 other location - About 15 mins to fix
                lib/geo_certs/endpoints/orders.rb on lines 94..98

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

                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

                            action :change_order_approval_email, :url => '/orders/:id/email.xml', :method => :put do
                              parameter 'order[approver_email]', :as => :approver_email, :required => true
                              parser Parsers::OrderParser do
                                element :order do
                                  eval(ELEMENTS)
                Severity: Minor
                Found in lib/geo_certs/endpoints/orders.rb and 1 other location - About 15 mins to fix
                lib/geo_certs/endpoints/orders.rb on lines 68..72

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

                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