dapi/moysklad

View on GitHub

Showing 3 of 5 total issues

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

    def self.build res
      body = res.body.force_encoding('utf-8')
      content_type = res.headers['content-type']

      if content_type.start_with? 'application/json'
Severity: Minor
Found in lib/moysklad/client/errors.rb - About 1 hr to fix

    Method initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def initialize login: nil, password: nil, logger: nil
        @client = Faraday.new URL do |conn|
          unless logger.nil?
            conn.response :detailed_logger, logger
            conn.request :curl, logger, :info
    Severity: Minor
    Found in lib/moysklad/client.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 parse_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def parse_response res
        body = res.body
        body.force_encoding 'utf-8' if  res.body.encoding.to_s == "ASCII-8BIT" && res.headers['content-type'].include?('charset=utf-8')
        Moysklad.logger.debug "Response [#{res.status}] with body #{body}"
    
    
    Severity: Minor
    Found in lib/moysklad/client.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