Comments (7)
Ash, Thanks for helping me analyse this on Friday! Our conclusion was that there are in fact two problems here:
First, LargeClass goes looking for the class in the object space, and if it finds it then it uses the in-memory class's method count. That shouldn't happen; the test should be based on the supplied chunk of source code. (Could you check that this is indeed occurring in your case? Please run the failing test on its own; if it passes, we know that reek is finding the class in memory from one of your other tests.)
And second, LargeClass should be disabled for in-memory reek parsing. Raised separately as #28.
from reek.
Well I only just got my head round it at the end :)
I will run the spec isolated in just a sec. But I remember we came to the conclusion that in general, the in-memory analysis will differ from the source-based analysis. eg my ugly bit of code:
{ :name => "Name", :identifier => "Identifier" }.each do |property, property_label|
define_method("dm_validate_#{property}_unique_in_study") do
property_unique_in_study?(property) || [false, "#{property_label} is already taken"]
end
end
MyClass.should_not reek
will see two methods here, but a source analysis will see none. Using eval
to generate a thousand-line method will be similarly different. And as you say, you may not even have the source that makes these changes. (Maybe this should all go under #28)
So how would you write the documentation to help reek users decide when to do an analysis source-based and when to do it object-based?
from reek.
Behaviour confirmed: in a Merb app, the following line in spec_helper.rb
causes the models to load, which causes reek to look in ObjectSpace:
Merb.start_environment(:testing => true, :adapter => 'runner', :environment => ENV['MERB_ENV'] || 'test')
I have the following line at the top of my reek_spec.rb
:
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
I could replace this with:
require 'reek'
require 'reek/spec'
But it will only take effect when that file is run in isolation. I guess I should wait for the bugfix?
from reek.
I believe this is fixed in e235ca9 (soon to be released as 1.1.3).
from reek.
Nudge me when 1.1.3 is out and I'll switch to the github gems to test it.
from reek.
Ashley pointed this release out to me, so I tested it in my environment it is indeed fixed. Many thanks.
from reek.
Good news -- thanks for the test!
from reek.
Related Issues (20)
- Offenses missing from JSON output HOT 4
- Reek breaking down! HOT 4
- Psych 4.0 has breaking changes HOT 10
- UncommunicativeVariableName rubocop recomendation oposite to rubycritic statment HOT 4
- Errors when building YARD index HOT 4
- Leading argument with argument forwarding issue HOT 1
- UtilityFunction and Concerns HOT 1
- Reek complaining about my simple mixin )-: HOT 2
- Fix nokey parameter HOT 5
- Fix ModuleInitialize false positive with custom Data constructor HOT 3
- Support Ruby 3.1 in Code Climate engine HOT 9
- Make new release with parser 3.2.x HOT 1
- Fix load error with REXML document HOT 7
- Variable assignment to self HOT 5
- Trailing comment in method body sometimes interferes with smell suppression comment HOT 1
- Add binding support for keyword arguments that override native keywords HOT 5
- Possible bug or improvement for error undefined method `keys' HOT 1
- Consider replacing the yaml schema validator HOT 5
- Remove Kwalify HOT 4
- Update to Parser 3.3.0 HOT 3
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 reek.