jemmons/BagOfTricks

View on GitHub

Showing 104 of 104 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public func map<FromValue, ToValue>(_ completion: @escaping (Result<ToValue, Error>)->Void, transform: @escaping (FromValue)->ToValue) -> (Result<FromValue, Error>)->Void {
    return { completion($0.map(transform)) }
}
Severity: Minor
Found in Sources/BagOfTricks/Free Functions/CompletionMaps.swift and 1 other location - About 1 hr to fix
Sources/BagOfTricks/Free Functions/CompletionMaps.swift on lines 35..37

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 69.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public func flatMap<FromValue, ToValue>(_ completion: @escaping (Result<ToValue, Error>)->Void, transform: @escaping (FromValue)throws->ToValue) -> (Result<FromValue, Error>)->Void {
    return { completion($0.flatMap { from in Result { try transform(from) } }) }
}
Severity: Minor
Found in Sources/BagOfTricks/Free Functions/CompletionMaps.swift and 1 other location - About 1 hr to fix
Sources/BagOfTricks/Free Functions/CompletionMaps.swift on lines 16..18

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 69.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public class FillIfReady<FillableObject>: BindIfReady<FillableObject, FillableObject.Value> where FillableObject: Fillable & AnyObject {
  public init() {
    super.init { obj, val in
      obj.fill(with: val)
    }
Severity: Minor
Found in Sources/BagOfTricks/Types/BindIfReady.swift and 1 other location - About 50 mins to fix
Sources/BagOfTricks/Types/BindIfReady.swift on lines 63..69

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 62.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public class WeakFillIfReady<FillableObject>: WeakBindIfReady<FillableObject, FillableObject.Value> where FillableObject: Fillable & AnyObject {
  public init() {
    super.init { obj, val in
      obj.fill(with: val)
    }
Severity: Minor
Found in Sources/BagOfTricks/Types/BindIfReady.swift and 1 other location - About 50 mins to fix
Sources/BagOfTricks/Types/BindIfReady.swift on lines 53..59

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 62.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public extension FloatingPoint {
  func clamp(to range: ClosedRange<Self>) -> Self {
    return Swift.max(range.lowerBound, Swift.min(range.upperBound, self))
  }
}
Severity: Minor
Found in Sources/BagOfTricks/Extensions/Numeric+Clamp.swift and 1 other location - About 45 mins to fix
Sources/BagOfTricks/Extensions/Numeric+Clamp.swift on lines 13..17

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 57.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public extension BinaryInteger {
  func clamp(to range: ClosedRange<Self>) -> Self {
    return Swift.max(range.lowerBound, Swift.min(range.upperBound, self))
  }
}
Severity: Minor
Found in Sources/BagOfTricks/Extensions/Numeric+Clamp.swift and 1 other location - About 45 mins to fix
Sources/BagOfTricks/Extensions/Numeric+Clamp.swift on lines 5..9

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 57.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  var assumingFalse: Bool {
    switch self {
    case .some(let some):
      return some
    case .none:
Severity: Minor
Found in Sources/BagOfTricks/Extensions/Optional+Assumptions.swift and 1 other location - About 30 mins to fix
Sources/BagOfTricks/Extensions/Optional+Assumptions.swift on lines 15..22

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 40.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  var assumingTrue: Bool {
    switch self {
    case .some(let some):
      return some
    case .none:
Severity: Minor
Found in Sources/BagOfTricks/Extensions/Optional+Assumptions.swift and 1 other location - About 30 mins to fix
Sources/BagOfTricks/Extensions/Optional+Assumptions.swift on lines 5..12

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 40.

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

Further Reading

Function next has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  public mutating func next() -> Element? {
    //We short circuit this becasue otherwise we'd have to grow the stack to the size of `xIt` before we find out there's no `next`.
    guard !yCol.isEmpty else {
      return nil
    }
Severity: Minor
Found in Sources/BagOfTricks/Sequences/CartesianProductSequence.swift - 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

Opening braces should be preceded by a single space and on the same line as the declaration.
Open

  public static func + (lhs:[Key:Value], rhs:[Key:Value]) -> [Key:Value]{

Opening braces should be preceded by a single space and on the same line as the declaration.
Open

public func given<T>(_ object:T, with: (_:T)->Void)->T{

Three lines between top-level items.
Open

}

Attributes should be on their own lines in functions and types, but on the same line as variables and imports.
Open

  @objc func refractoryTimeUp() {

Colons should be next to the identifier when specifying a type and next to the key in dictionary literals.
Open

private var _timebaseInfo: mach_timebase_info = mach_timebase_info(numer:0, denom:0)

There must be two or zero lines between second-level items.
Open

  public typealias Element = (X.Element, Y.Element)

Three lines between top-level items.
Open

import Foundation

Variables should not have redundant type annotation
Open

private var _timebaseInfo: mach_timebase_info = mach_timebase_info(numer:0, denom:0)

Colons should be next to the identifier when specifying a type and next to the key in dictionary literals.
Open

  public static func + (lhs:[Key:Value], rhs:[Key:Value]) -> [Key:Value]{

Colons should be next to the identifier when specifying a type and next to the key in dictionary literals.
Open

  public static func + (lhs:[Key:Value], rhs:[Key:Value]) -> [Key:Value]{

Files should have a single trailing newline.
Open

Severity
Category
Status
Source
Language