digitalprog/ruby_provisioning_api

View on GitHub

Showing 3 of 5 total issues

Method prepare_xml_request has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def prepare_xml_request(params = {})
      Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
        xml.send(:'atom:entry', 'xmlns:atom' => 'http://www.w3.org/2005/Atom', 'xmlns:apps' => 'http://schemas.google.com/apps/2006') {
          xml.send(:'atom:category', 'scheme' => 'http://schemas.google.com/g/2005#kind', 'term' => 'http://schemas.google.com/apps/2006#emailList')
          xml.send(:'apps:property', 'name' => 'email', 'value' => params[:owner_id]) if params.has_key? :owner_id
Severity: Minor
Found in lib/ruby_provisioning_api/group.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 prepare_xml_request has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def prepare_xml_request(user_name, suspended, quota, family_name, given_name)
Severity: Minor
Found in lib/ruby_provisioning_api/user.rb - About 35 mins to fix

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

        def save(save_options = {:validate => true})
          if save_options[:validate]
            return false unless valid?
          end
          builder = prepare_xml_request(user_name, suspended, quota, family_name, given_name)
    Severity: Minor
    Found in lib/ruby_provisioning_api/user.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