Comments (7)
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.
;)
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.
I meant your code that breaks it!
from cane.
How can I discover the line and number from there?
from cane.
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.
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.
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)
- Can I get write access?
- Ruby 3 incompatibility (call to `File.exists?`)
- Cane HOT 1
- New vs. Old Hash syntax HOT 1
- Review guard-cane HOT 2
- Vim plugin HOT 4
- value "class" raises exception in multiline definition of array using %w HOT 3
- Classes with no methods still require a comment if they are defined within a class HOT 2
- Consider switching to Parser? HOT 2
- JsonFormatter not working from rake task
- Invalid byte sequence in UTF-8 (ArgumentError) HOT 1
- Allow Cane::RakeTask to pick up .cane files in subdirectories HOT 1
- License missing from gemspec HOT 1
- Global .cane file HOT 2
- Recursively run cane over a directory of files HOT 5
- Load .cane files when scanning subdirectories
- Rspec integration in spec_helper.rb HOT 1
- feature request: alert on no newline at end of file HOT 1
- bug: stack level too deep HOT 2
- bug: stack level too deep (with repro) HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cane.