Giter Club home page Giter Club logo

Comments (7)

xaviershay avatar xaviershay commented on July 19, 2024

Open up /Users/sobrinho/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/cane-1.0.0/lib/cane/abc_check.rb and print out the file/line number. From there, hopefully you can narrow down a minimal code snippet to reproduce, and post that here. Thanks!

from cane.

sobrinho avatar sobrinho commented on July 19, 2024

;)

 27     # Recursive function to process an AST. The `complexity` variable mutates,
 28     # which is a bit confusing. `nesting` does not.
 29     def process_ast(node, complexity = {}, nesting = [])
 30       if method_nodes.include?(node[0])
 31         nesting = nesting + [node[1][1]]
 32         complexity[nesting.join(" > ")] = calculate_abc(node)
 33       elsif container_nodes.include?(node[0])
 34         parent = if node[1][1][1].is_a?(Symbol)
 35           node[1][1][1]
 36         else
 37           node[1][-1][1]
 38         end
 39         nesting = nesting + [parent]
 40       end
 41 
 42       if node.is_a? Array
 43         node[1..-1].each { |n| process_ast(n, complexity, nesting) if n }
 44       end
 45       complexity
 46     end

from cane.

xaviershay avatar xaviershay commented on July 19, 2024

I meant your code that breaks it!

from cane.

sobrinho avatar sobrinho commented on July 19, 2024

How can I discover the line and number from there?

from cane.

xaviershay avatar xaviershay commented on July 19, 2024

Work back the stack trace a step or two, the find_violations method. Might not be able to get line and number, but at least will give you file name.

from cane.

conanr avatar conanr commented on July 19, 2024

I ran into the same issue when evaluating a fellow student's Ruby program for style & complexity using the cane gem. He had a class definition that had not been closed with an "end" statement. But since the class was not being used anywhere, it did not cause any runtime errors.

class Load
  def file_load
    @file = CSV.open(filename, :headers => true,
                                :header_converters => :symbol)
  end

Running the command cane --abc-glob '**/*.rb' returned the same trace regarding the same error.

from cane.

xaviershay avatar xaviershay commented on July 19, 2024

I have seen this once also on a syntax error. Not sure what correct behaviour is here (but definitely raising awkwardly is wrong).

from cane.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.