zhuhaow/NEKit

View on GitHub
src/RawSocket/NWUDPSocket.swift

Summary

Maintainability
A
30 mins
Test Coverage

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

    public override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
        guard keyPath == "state" else {
            return
        }
        
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift and 1 other location - About 30 mins to fix
src/RawSocket/NWTCPSocket.swift on lines 219..242

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

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

Line should not have any trailing whitespace
Open

    
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

        
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

    
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

    
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

        
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

        
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

    
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

        
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

        
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

                
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

     
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

    
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

        
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

                
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

        
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

    
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

     
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Colon at column 114 should have no spaces before it
Open

    public override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

colon-whitespace

There should be no whitespace preceding the colon, exactly one whitespace after the colon for: * var, class, struct, protocol, extension, func, and tuple declarations * dict literals and types * case statements

However, for conditional expressions there should be a single whitespace before and after the colon.

Variable declarations

Preferred

var x: Int = 2

Not Preferred

var x : Int
var y:   String

Dictionary literals and types

Preferred

var x = [ 'key1': 1, 'key2': 2 ]
var y: [ Int: String ]

Not Preferred

var x = [ 'key1' : 1, 'key2':  3]
var y: [ Int :    String ]

Case statements

Preferred

switch character {
case "a": doSomething(a);
default: alert();
}

Not Preferred

switch character {
case "a" : doSomething(a);
default:     alert();
}

Class, Struct, Protocol, and Extension declarations

Preferred

class ClassName: BaseClass {
}

struct StructName: BaseStruct {
}

protocol ProtocolName: AnotherProtocol {
}

extension TypeName: ProtocolName {
}

Not Preferred

class ClassName : BaseClass {
}

struct StructName:  BaseStruct {
}

protocol ProtocolName:AnotherProtocol {
}

extension TypeName : ProtocolName {
}

Tuple declarations

Preferred

var y = (key: 1, value: 2)

Not Preferred

var y = (key:1, value : 2)

Function declarations

Preferred

func someFunction<t: someclass u: someprotocol>(someT: T, someU: U) {
}</t:>

Not Preferred

func someFunction<t : someclass u:someprotocol>(someT: T, someU: U) {
}</t>

Conditional expressions

Preferred

var x = condition ? a : b

Not Preferred

var x = condition ? a: b
var x = condition ? a   : b

Line should not have any trailing whitespace
Open

    
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

    
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

    
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

        
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

        
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

                
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

    
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

     
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

        
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

    
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

        
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Line should not have any trailing whitespace
Open

    
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

trailing-whitespace

Flag whitespace after the last non-whitespace character on each line until the newline.

Preferred

let number = 42¬

Not Preferred

let number = 42••¬

Parameter clause in closure signature should be preceded by exactly one space
Open

        session.writeMultipleDatagrams(self.pendingWriteData) {_ in
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift by tailor

There are no issues that match your filters.

Category
Status