SvenTiigi/STLocationRequest

View on GitHub

Showing 13 of 13 total issues

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

        private func getImageWithColor(_ color: UIColor, size: CGSize) -> UIImage? {
            let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
            UIGraphicsBeginImageContextWithOptions(size, false, 0)
            color.setFill()
            UIRectFill(rect)
Severity: Major
Found in Sources/Button/STLocationRequestController+Button.swift and 1 other location - About 1 hr to fix
Example-iOS/Extensions/PresentButton.swift on lines 60..68

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

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

    private func getImageWithColor(_ color: UIColor, size: CGSize) -> UIImage? {
        let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
        UIGraphicsBeginImageContextWithOptions(size, false, 0)
        color.setFill()
        UIRectFill(rect)
Severity: Major
Found in Example-iOS/Extensions/PresentButton.swift and 1 other location - About 1 hr to fix
Sources/Button/STLocationRequestController+Button.swift on lines 75..83

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

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

    internal class func animatedImageWithSource(_ source: CGImageSource) -> UIImage? {
        let count = CGImageSourceGetCount(source)
        var images = [CGImage]()
        var delays = [Int]()
        
Severity: Minor
Found in Example-iOS/Extensions/UIImage+Gif.swift - About 1 hr to fix

    Function gcdForPair has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        internal class func gcdForPair(_ a: Int?, _ b: Int?) -> Int {
            var a = a
            var b = b
            // Check if one of them is nil
            if b == nil || a == nil {
    Severity: Minor
    Found in Example-iOS/Extensions/UIImage+Gif.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

    Function makeConstraints has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        func makeConstraints() {
            // Check if running on simulator
            if self.isSimulator {
                // Layout simulator warning label
                self.simulatorWarningLabel.translatesAutoresizingMaskIntoConstraints = false
    Severity: Minor
    Found in Example-iOS/ViewController.swift - About 1 hr to fix

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

          internal class func gcdForPair(_ a: Int?, _ b: Int?) -> Int {
              var a = a
              var b = b
              // Check if one of them is nil
              if b == nil || a == nil {
      Severity: Minor
      Found in Example-iOS/Extensions/UIImage+Gif.swift - About 1 hr to fix

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

                public var allowButton: Button = (
                    title: "Alright",
                    titleColor: .white,
                    font: .systemFont(ofSize: 21),
                    backgroundColor: UIColor.white.withAlphaComponent(0.08),
        Sources/Configuration/STLocationRequestController+Configuration.swift on lines 40..50

        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

                public var notNowButton: Button = (
                    title: "Not now",
                    titleColor: .white,
                    font: .systemFont(ofSize: 21),
                    backgroundColor: UIColor.white.withAlphaComponent(0.08),
        Sources/Configuration/STLocationRequestController+Configuration.swift on lines 27..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 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

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

                let locationRequestController = STLocationRequestController { config in
                    // Perform configuration
                    config.title.text = "We need your location for some awesome features"
                    config.allowButton.title = "Alright"
                    config.notNowButton.title = "Not now"
        Severity: Minor
        Found in Example-tvOS/ViewController.swift and 1 other location - About 55 mins to fix
        Example-iOS/ViewController+STLocationRequest.swift on lines 20..28

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

        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

                let locationRequestController = STLocationRequestController { config in
                    // Perform configuration
                    config.title.text = "We need your location for some awesome features"
                    config.allowButton.title = "Alright"
                    config.notNowButton.title = "Not now"
        Severity: Minor
        Found in Example-iOS/ViewController+STLocationRequest.swift and 1 other location - About 55 mins to fix
        Example-tvOS/ViewController.swift on lines 31..39

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

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

            internal class func animatedImageWithSource(_ source: CGImageSource) -> UIImage? {
                let count = CGImageSourceGetCount(source)
                var images = [CGImage]()
                var delays = [Int]()
                
        Severity: Minor
        Found in Example-iOS/Extensions/UIImage+Gif.swift - About 45 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

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

                override func layoutSubviews() {
                    super.layoutSubviews()
                    // Check if current background image is nil
                    if self.currentBackgroundImage == nil {
                        // Set the backgroundimage
        Severity: Minor
        Found in Sources/Button/STLocationRequestController+Button.swift and 1 other location - About 35 mins to fix
        Example-iOS/Extensions/PresentButton.swift on lines 37..50

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

        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

            override func layoutSubviews() {
                super.layoutSubviews()
                // Check if current background image is nil
                if self.currentBackgroundImage == nil {
                    // Set the backgroundimage
        Severity: Minor
        Found in Example-iOS/Extensions/PresentButton.swift and 1 other location - About 35 mins to fix
        Sources/Button/STLocationRequestController+Button.swift on lines 52..65

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

        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

        Severity
        Category
        Status
        Source
        Language