Maquech/MX-Banxico

View on GitHub

Showing 7 of 7 total issues

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

    def nombre(identificador, tipo = nil)
      nom = nil
      if tipo.nil?
        tipos.each do |t|
          nom = busca_nombre(identificador, t)
Severity: Minor
Found in lib/MX/Banxico/series.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 realizar_operacion has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def realizar_operacion(op, intentos = 5)
    raise ArgumentError.new("La operación #{op} no está soportada.") unless OPERACIONES_WS.member?(op.to_sym)
    raise ArgumentError.new("El número de intentos debe ser mayor o igual a 1.") if (!intentos.is_a?(Integer) or intentos < 1)
    errores = ""
    1.upto(intentos) do |intento|
Severity: Minor
Found in lib/MX/Banxico/web_services/web_service.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 <=> has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def <=>(otro)
    if self == otro
      0
    elsif @moneda == otro.moneda
      if @fecha == otro.fecha
Severity: Minor
Found in lib/MX/Banxico/tipo_de_cambio.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

Method procesar_series has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def procesar_series(xml_doc, ids_series)
      historico = []
      xml_doc.root.xpath("bm:DataSet/bm:Series").each do |serie|
        if serie["IDSERIE"] && ids_series.include?(serie["IDSERIE"])
          begin
Severity: Minor
Found in lib/MX/Banxico/historico/tipo_de_cambio.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

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

  def obtener(tipo, intentos = 5)
    raise ArgumentError.new("El tipo de cambio no está soportado (#{tipo}).") unless TIPOS_DE_CAMBIO.member?(tipo.to_sym)
    respuesta = realizar_operacion(:tipos_de_cambio_banxico, intentos)
    if respuesta.errores?
      return respuesta.errores
Severity: Minor
Found in lib/MX/Banxico/web_services/tipo_de_cambio.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

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

    def procesar_respuesta(respuesta, opts = {})
      xml_doc = Nokogiri::XML(respuesta, nil, 'UTF-8')
      if xml_doc.root.respond_to?(:xpath)
        if opts[:id_serie] && opts[:serie]
          return procesar_serie(xml_doc, opts[:id_serie], opts[:serie])
Severity: Minor
Found in lib/MX/Banxico/historico/tipo_de_cambio.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 procesar_valor_en_mxn has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def procesar_valor_en_mxn(valor_en_mxn)
    if valor_en_mxn.is_a?(Float)
      @valor_en_mxn = valor_en_mxn
    elsif valor_en_mxn.is_a?(String)
      if valor_en_mxn =~ /^\d+(\.\d+)?$/
Severity: Minor
Found in lib/MX/Banxico/tipo_de_cambio.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