Showing 124 of 124 total issues
Method single
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def single(&block)
return select(&block).single if block_given?
AnonymousObservable.new do |observer|
seen_value = false
value = nil
- Read upRead up
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 advance_to
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def advance_to(time)
due_to_clock = time<=>clock
raise 'Time is out of range' if due_to_clock < 0
return if due_to_clock == 0
- Read upRead up
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 unsubscribe
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def unsubscribe
subscription = nil
@gate.synchronize do
if @subscription
unless @primary_unsubscribed
- Read upRead up
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 run_trampoline
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def run_trampoline(queue)
while item = queue.shift
unless item.cancelled?
wait = item.due_time - Scheduler.now.to_i
sleep wait if wait > 0
- Read upRead up
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 single_or_default
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def single_or_default(default_value = nil, &block)
return select(&block).single_or_default(default_value) if block_given?
AnonymousObservable.new do |observer|
seen_value = false
value = nil
- Read upRead up
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 tap
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def tap(observer)
raise ArgumentError.new 'Observer cannot be nil' unless observer
AnonymousObservable.new do |obs|
new_obs = Rx::Observer.configure do |o|
Method invoke_recursive
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def invoke_recursive(scheduler, pair)
group = CompositeSubscription.new
gate = Mutex.new
state = pair[:state]
action = pair[:action]
Method while
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def while(condition, source)
enum = Enumerator.new {|y|
while condition.call
y << source
end
Method when
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def when(*plans)
AnonymousObservable.new do |observer|
active_plans = []
external_subscriptions = {}
out_observer = Observer.configure {|o|
Method generate
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate(initial_state, condition, iterate, result_selector, scheduler = CurrentThreadScheduler.instance)
AnonymousObservable.new do |observer|
state = initial_state
first = true
Method skip_until
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def skip_until(other)
raise ArgumentError.new 'Other cannot be nil' unless other
AnonymousObservable.new do |observer|
source_subscription = SingleAssignmentSubscription.new
- Read upRead up
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 take
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def take(count, scheduler = ImmediateScheduler.instance)
return Observable.empty(scheduler) if count == 0
AnonymousObservable.new do |observer|
- Read upRead up
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 from
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def from(iterable, map_fn = nil, scheduler = CurrentThreadScheduler.instance)
it = iterable.to_enum
AnonymousObservable.new {|observer|
i = 0
scheduler.schedule_recursive lambda {|this|
- Read upRead up
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 match
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def match
has_values = true
@join_observer_array.each {|v|
if v.queue.length == 0
has_values = false
- Read upRead up
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 configure
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def configure(options = {})
options.each {|key,_|
unless [:created, :subscribed, :disposed].include? key
raise ArgumentError, "Should be specified whether :created, :subscribed or :disposed, but the #{key.inspect}"
end
Method merge_all
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def merge_all
AnonymousObservable.new do |observer|
gate = Monitor.new
stopped = false
m = SingleAssignmentSubscription.new
Method from
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def from(iterable, map_fn = nil, scheduler = CurrentThreadScheduler.instance)
it = iterable.to_enum
AnonymousObservable.new {|observer|
i = 0
scheduler.schedule_recursive lambda {|this|
Similar blocks of code found in 2 locations. Consider refactoring. Open
AnonymousObservable.new do |observer|
value = nil
seen_value = false
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 48.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
AnonymousObservable.new do |observer|
value = nil
has_value = false
new_obs = Observer.configure do |o|
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 48.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method concat_map_observer
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def concat_map_observer(on_next, on_error, on_completed)
AnonymousObservable.new do |observer|
index = 0
subscribe(
- Read upRead up
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"