FabrizioBrancati/BFKit-Swift

View on GitHub
Sources/BFKit/Linux/Foundation/Date+Extensions.swift

Summary

Maintainability
D
1 day
Test Coverage

File Date+Extensions.swift has 320 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Foundation

// MARK: - Date extension

/// This extension add some useful functions to Date.
Severity: Minor
Found in Sources/BFKit/Linux/Foundation/Date+Extensions.swift - About 3 hrs to fix

    Function update has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        mutating func update(components: [EditableDateComponents: Int]) {
            #if os(Linux)
                let calendar = Calendar(identifier: .gregorian)
            #else
                let calendar = Calendar.autoupdatingCurrent
    Severity: Minor
    Found in Sources/BFKit/Linux/Foundation/Date+Extensions.swift - About 1 hr to fix

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

          var month: Int {
              get {
                  #if os(Linux)
                      let calendar = Calendar(identifier: .gregorian)
                  #else
      Severity: Major
      Found in Sources/BFKit/Linux/Foundation/Date+Extensions.swift and 5 other locations - About 1 hr to fix
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 36..49
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 68..81
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 84..97
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 100..113
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 116..129

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

      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

          var hour: Int {
              get {
                  #if os(Linux)
                      let calendar = Calendar(identifier: .gregorian)
                  #else
      Severity: Major
      Found in Sources/BFKit/Linux/Foundation/Date+Extensions.swift and 5 other locations - About 1 hr to fix
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 36..49
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 52..65
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 68..81
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 100..113
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 116..129

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

      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

          var minute: Int {
              get {
                  #if os(Linux)
                      let calendar = Calendar(identifier: .gregorian)
                  #else
      Severity: Major
      Found in Sources/BFKit/Linux/Foundation/Date+Extensions.swift and 5 other locations - About 1 hr to fix
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 36..49
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 52..65
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 68..81
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 84..97
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 116..129

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

      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

          var second: Int {
              get {
                  #if os(Linux)
                      let calendar = Calendar(identifier: .gregorian)
                  #else
      Severity: Major
      Found in Sources/BFKit/Linux/Foundation/Date+Extensions.swift and 5 other locations - About 1 hr to fix
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 36..49
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 52..65
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 68..81
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 84..97
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 100..113

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

      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

          var day: Int {
              get {
                  #if os(Linux)
                      let calendar = Calendar(identifier: .gregorian)
                  #else
      Severity: Major
      Found in Sources/BFKit/Linux/Foundation/Date+Extensions.swift and 5 other locations - About 1 hr to fix
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 36..49
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 52..65
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 84..97
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 100..113
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 116..129

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

      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

          var year: Int {
              get {
                  #if os(Linux)
                      let calendar = Calendar(identifier: .gregorian)
                  #else
      Severity: Major
      Found in Sources/BFKit/Linux/Foundation/Date+Extensions.swift and 5 other locations - About 1 hr to fix
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 52..65
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 68..81
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 84..97
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 100..113
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 116..129

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

      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

          func localizedMonth() -> String {
              let dateFormatter = DateFormatter()
              dateFormatter.dateFormat = "MMMM"
              
              if let locale = NSLocale.preferredLanguages.first {
      Severity: Minor
      Found in Sources/BFKit/Linux/Foundation/Date+Extensions.swift and 1 other location - About 1 hr to fix
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 496..505

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

      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

          func localizedWeekday() -> String {
              let dateFormatter = DateFormatter()
              dateFormatter.dateFormat = "EEEE"
              
              if let locale = NSLocale.preferredLanguages.first {
      Severity: Minor
      Found in Sources/BFKit/Linux/Foundation/Date+Extensions.swift and 1 other location - About 1 hr to fix
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 510..519

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

      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

          func isGreaterThan(_ date: Date) -> Bool {
              var isGreater = false
              if compare(date) == ComparisonResult.orderedDescending {
                  isGreater = true
              }
      Severity: Minor
      Found in Sources/BFKit/Linux/Foundation/Date+Extensions.swift and 1 other location - About 45 mins to fix
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 466..473

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

      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

          func isLessThan(_ date: Date) -> Bool {
              var isLess = false
              if compare(date) == ComparisonResult.orderedAscending {
                  isLess = true
              }
      Severity: Minor
      Found in Sources/BFKit/Linux/Foundation/Date+Extensions.swift and 1 other location - About 45 mins to fix
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 453..460

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

      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 weekday: Int {
              #if os(Linux)
                  let calendar = Calendar(identifier: .gregorian)
              #else
                  let calendar = Calendar.autoupdatingCurrent
      Severity: Minor
      Found in Sources/BFKit/Linux/Foundation/Date+Extensions.swift and 1 other location - About 40 mins to fix
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 132..140

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

      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 nanosecond: Int {
              #if os(Linux)
                  let calendar = Calendar(identifier: .gregorian)
              #else
                  let calendar = Calendar.autoupdatingCurrent
      Severity: Minor
      Found in Sources/BFKit/Linux/Foundation/Date+Extensions.swift and 1 other location - About 40 mins to fix
      Sources/BFKit/Linux/Foundation/Date+Extensions.swift on lines 150..158

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

      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

      There are no issues that match your filters.

      Category
      Status