rwbutler/Hash

View on GitHub

Showing 17 of 17 total issues

Function data has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    func data(operation: CCOperation) -> Data {
        var outLength = Int(0)
        let inputData = message
        let length = (algorithm.blockSize() + inputData.count)
        var outputData = Data(count: length)
Severity: Minor
Found in Hash/Classes/Cryptography/Cryptable.swift - About 1 hr 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

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

    public init?(message: String, key: String, iv: String? = nil, encoding: String.Encoding = .utf8, algorithm: Algorithm) {
        guard let keyData = key.data(using: encoding), let messageData = message.data(using: encoding) else {
            return nil
        }
        self.algorithm = algorithm
Severity: Major
Found in Hash/Classes/Cryptography/DecryptedData.swift and 1 other location - About 1 hr to fix
Hash/Classes/Cryptography/EncryptedData.swift on lines 33..41

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

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

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

    public init?(message: String, key: String, iv: String? = nil, encoding: String.Encoding = .utf8, algorithm: Algorithm) {
        guard let keyData = key.data(using: encoding), let messageData = message.data(using: encoding) else {
            return nil
        }
        self.algorithm = algorithm
Severity: Major
Found in Hash/Classes/Cryptography/EncryptedData.swift and 1 other location - About 1 hr to fix
Hash/Classes/Cryptography/DecryptedData.swift on lines 33..41

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

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 data has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    func data(operation: CCOperation) -> Data {
        var outLength = Int(0)
        let inputData = message
        let length = (algorithm.blockSize() + inputData.count)
        var outputData = Data(count: length)
Severity: Minor
Found in Hash/Classes/Cryptography/Cryptable.swift - About 1 hr to fix

    Function data has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public func data() -> Data {
            let data = message
            let length = algorithm.digestLength()
            var digestData = Data(count: length)
            _ = digestData.withUnsafeMutableBytes { digestBytes -> UInt8 in
    Severity: Minor
    Found in Hash/Classes/Message Digest/Hash.swift - About 1 hr to fix

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

          public var description: String {
              switch self {
              case .md2:
                  return "MD2"
              case .md4:
      Severity: Major
      Found in Hash/Classes/Message Digest/HashAlgorithm.swift and 1 other location - About 1 hr to fix
      Example/Tests/HashAlgorithm+ExpectedString.swift on lines 15..34

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

      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 expectedString: String {
              switch self {
              case .md2:
                  return "315f7c67223f01fb7cab4b95100e872e"
              case .md4:
      Severity: Major
      Found in Example/Tests/HashAlgorithm+ExpectedString.swift and 1 other location - About 1 hr to fix
      Hash/Classes/Message Digest/HashAlgorithm.swift on lines 25..44

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

      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 6 locations. Consider refactoring.
      Open

          func testAES192EncryptionProducesExpectedString() {
              guard let cipherText = CipherText(message: "Hello World!", key: "012345678901234567890123", iv: "0123456789012345", algorithm: .aes192) else {
                  XCTFail("It is possible to encrypt using the provided values.")
                  return
              }
      Severity: Major
      Found in Example/Tests/Tests.swift and 5 other locations - About 1 hr to fix
      Example/Tests/Tests.swift on lines 39..47
      Example/Tests/Tests.swift on lines 49..57
      Example/Tests/Tests.swift on lines 69..77
      Example/Tests/Tests.swift on lines 79..87
      Example/Tests/Tests.swift on lines 89..97

      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 6 locations. Consider refactoring.
      Open

          func testAES128EncryptionProducesExpectedString() {
              guard let cipherText = CipherText(message: "Hello World!", key: "0123456789012345", iv: "0123456789012345", algorithm: .aes128) else {
                  XCTFail("It is possible to encrypt using the provided values.")
                  return
              }
      Severity: Major
      Found in Example/Tests/Tests.swift and 5 other locations - About 1 hr to fix
      Example/Tests/Tests.swift on lines 49..57
      Example/Tests/Tests.swift on lines 59..67
      Example/Tests/Tests.swift on lines 69..77
      Example/Tests/Tests.swift on lines 79..87
      Example/Tests/Tests.swift on lines 89..97

      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 6 locations. Consider refactoring.
      Open

          func testAES192EncryptionWithoutIVProducesExpectedString() {
              guard let cipherText = CipherText(message: "Hello World!", key: "012345678901234567890123", iv: nil, algorithm: .aes192) else {
                  XCTFail("It is possible to encrypt using the provided values.")
                  return
              }
      Severity: Major
      Found in Example/Tests/Tests.swift and 5 other locations - About 1 hr to fix
      Example/Tests/Tests.swift on lines 39..47
      Example/Tests/Tests.swift on lines 49..57
      Example/Tests/Tests.swift on lines 59..67
      Example/Tests/Tests.swift on lines 79..87
      Example/Tests/Tests.swift on lines 89..97

      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 6 locations. Consider refactoring.
      Open

          func testAES256EncryptionWithoutIVProducesExpectedString() {
              guard let cipherText = CipherText(message: "Hello World!", key: "01234567890123450123456789012345", iv: nil, algorithm: .aes256) else {
                  XCTFail("It is possible to encrypt using the provided values.")
                  return
              }
      Severity: Major
      Found in Example/Tests/Tests.swift and 5 other locations - About 1 hr to fix
      Example/Tests/Tests.swift on lines 39..47
      Example/Tests/Tests.swift on lines 49..57
      Example/Tests/Tests.swift on lines 59..67
      Example/Tests/Tests.swift on lines 69..77
      Example/Tests/Tests.swift on lines 79..87

      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 6 locations. Consider refactoring.
      Open

          func testAES128EncryptionWithoutIVProducesExpectedString() {
              guard let cipherText = CipherText(message: "Hello World!", key: "0123456789012345", iv: nil, algorithm: .aes128) else {
                  XCTFail("It is possible to encrypt using the provided values.")
                  return
              }
      Severity: Major
      Found in Example/Tests/Tests.swift and 5 other locations - About 1 hr to fix
      Example/Tests/Tests.swift on lines 39..47
      Example/Tests/Tests.swift on lines 59..67
      Example/Tests/Tests.swift on lines 69..77
      Example/Tests/Tests.swift on lines 79..87
      Example/Tests/Tests.swift on lines 89..97

      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 6 locations. Consider refactoring.
      Open

          func testAES256EncryptionProducesExpectedString() {
              guard let cipherText = CipherText(message: "Hello World!", key: "01234567890123450123456789012345", iv: "0123456789012345", algorithm: .aes256) else {
                  XCTFail("It is possible to encrypt using the provided values.")
                  return
              }
      Severity: Major
      Found in Example/Tests/Tests.swift and 5 other locations - About 1 hr to fix
      Example/Tests/Tests.swift on lines 39..47
      Example/Tests/Tests.swift on lines 49..57
      Example/Tests/Tests.swift on lines 59..67
      Example/Tests/Tests.swift on lines 69..77
      Example/Tests/Tests.swift on lines 89..97

      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

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

          public init(message: Data, key: Data, iv: Data? = nil, algorithm: Algorithm) {
              self.algorithm = algorithm
              self.ivData = iv
              self.keyData = key
              self.message = message
      Severity: Minor
      Found in Hash/Classes/Cryptography/DecryptedData.swift and 1 other location - About 50 mins to fix
      Hash/Classes/Cryptography/EncryptedData.swift on lines 26..31

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

      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

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

          public init(message: Data, key: Data, iv: Data? = nil, algorithm: Algorithm) {
              self.algorithm = algorithm
              self.ivData = iv
              self.keyData = key
              self.message = message
      Severity: Minor
      Found in Hash/Classes/Cryptography/EncryptedData.swift and 1 other location - About 50 mins to fix
      Hash/Classes/Cryptography/DecryptedData.swift on lines 26..31

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

      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 data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public func data() -> Data {
              let data = message
              let length = hashAlgorithm.digestLength()
              var digestData = Data(count: length)
              _ = digestData.withUnsafeMutableBytes { digestBytes -> UInt8 in
      Severity: Minor
      Found in Hash/Classes/Message Authentication Codes/HMAC.swift - About 35 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

      Function data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public func data() -> Data {
              let data = message
              let length = algorithm.digestLength()
              var digestData = Data(count: length)
              _ = digestData.withUnsafeMutableBytes { digestBytes -> UInt8 in
      Severity: Minor
      Found in Hash/Classes/Message Digest/Hash.swift - About 35 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

      Severity
      Category
      Status
      Source
      Language