devicekit/DeviceKit

View on GitHub

Showing 18 of 18 total issues

File gyb.py has 981 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
# GYB: Generate Your Boilerplate (improved names welcome; at least
# this one's short).  See -h output for instructions

from __future__ import print_function
Severity: Major
Found in Utils/gyb.py - About 2 days to fix

    File Device.generated.swift has 724 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #if os(watchOS)
    import WatchKit
    #else
    import UIKit
    #endif
    Severity: Major
    Found in CocoaPodsVerification/Pods/DeviceKit/Source/Device.generated.swift - About 1 day to fix

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

            switch self {
              case .iPodTouch5: return 4
              case .iPodTouch6: return 4
              case .iPhone4: return 3.5
              case .iPhone4s: return 3.5
      CocoaPodsVerification/Pods/DeviceKit/Source/Device.generated.swift on lines 771..812

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

      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

          switch self {
            case .iPodTouch5: return 326
            case .iPodTouch6: return 326
            case .iPhone4: return 326
            case .iPhone4s: return 326
      CocoaPodsVerification/Pods/DeviceKit/Source/Device.generated.swift on lines 378..419

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

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

          def token_generator(self, base_tokens):
              r"""Given an iterator over (kind, text, match) triples (see
              tokenize_template above), return a refined iterator over
              token_kinds.
      
      
      Severity: Minor
      Found in Utils/gyb.py - About 3 hrs 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 mapToDevice has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public static func mapToDevice(identifier: String) -> Device { // swiftlint:disable:this cyclomatic_complexity
          #if os(iOS)
            switch identifier {
            case "iPod5,1": return iPodTouch5
            case "iPod7,1": return iPodTouch6
      Severity: Major
      Found in CocoaPodsVerification/Pods/DeviceKit/Source/Device.generated.swift - About 2 hrs to fix

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

        def tokenize_template(template_text):
            r"""Given the text of a template, returns an iterator over
            (tokenType, token, match) tuples.
        
            **Note**: this is template syntax tokenization, not Python
        Severity: Minor
        Found in Utils/gyb.py - 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

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

            switch self {
            case .appleWatchSeries0_38mm: return 290
            case .appleWatchSeries0_42mm: return 303
            case .appleWatchSeries1_38mm: return 290
            case .appleWatchSeries1_42mm: return 303
        CocoaPodsVerification/Pods/DeviceKit/Source/Device.generated.swift on lines 421..434

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

        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

              switch self {
              case .appleWatchSeries0_38mm: return 1.5
              case .appleWatchSeries0_42mm: return 1.6
              case .appleWatchSeries1_38mm: return 1.5
              case .appleWatchSeries1_42mm: return 1.6
        CocoaPodsVerification/Pods/DeviceKit/Source/Device.generated.swift on lines 814..827

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

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

        def split_gyb_lines(source_lines):
            r"""Return a list of lines at which to split the incoming source
        
            These positions represent the beginnings of python line groups that
            will require a matching %end construct if they are to be closed.
        Severity: Minor
        Found in Utils/gyb.py - 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

                switch UIDevice.current.batteryState {
                case .charging: self = .charging(batteryLevel)
                case .full: self = .full
                case .unplugged:self = .unplugged(batteryLevel)
                case .unknown: self = .full // Should never happen since `batteryMonitoring` is enabled.
        CocoaPodsVerification/Pods/DeviceKit/Source/Device.generated.swift on lines 986..991

        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

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

                switch WKInterfaceDevice.current().batteryState {
                case .charging: self = .charging(batteryLevel)
                case .full: self = .full
                case .unplugged:self = .unplugged(batteryLevel)
                case .unknown: self = .full // Should never happen since `batteryMonitoring` is enabled.
        CocoaPodsVerification/Pods/DeviceKit/Source/Device.generated.swift on lines 972..977

        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

        Function __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(self, context):
        
                source = ''
                source_line_count = 0
        
        
        Severity: Minor
        Found in Utils/gyb.py - 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

        Function tokenize_python_to_unmatched_close_curly has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def tokenize_python_to_unmatched_close_curly(source_text, start, line_starts):
            """Apply Python's tokenize to source_text starting at index start
            while matching open and close curly braces.  When an unmatched
            close curly brace is found, return its index.  If not found,
            return len(source_text).  If there's a tokenization error, return
        Severity: Minor
        Found in Utils/gyb.py - 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

        Function append_text has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def append_text(self, text, file, line):
                # see if we need to inject a line marker
                if self.line_directive:
                    if (file, line) != self.last_file_line:
                        # We can only insert the line directive at a line break
        Severity: Minor
        Found in Utils/gyb.py - 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

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

            def execute(self, context):
                # Save __children__ from the local bindings
                save_children = context.local_bindings.get('__children__')
                # Execute the code with our __children__ in scope
                context.local_bindings['__children__'] = self.children
        Severity: Minor
        Found in Utils/gyb.py - 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

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

        //===----------------------------------------------------------------------===//
        //
        // This source file is part of the DeviceKit open source project
        //
        // Copyright © 2014 - 2018 Dennis Weissmann and the DeviceKit project authors
        CocoaPodsVerification/Pods/DeviceKit/Source/Device.generated.swift on lines 1..1150
        CocoaPodsVerification/Pods/DeviceKit/Source/Device.generated.swift on lines 1..1150

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

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

          public static func mapToDevice(identifier: String) -> Device { // swiftlint:disable:this cyclomatic_complexity
            #if os(iOS)
              switch identifier {
              case "iPod5,1": return iPodTouch5
              case "iPod7,1": return iPodTouch6
        Severity: Minor
        Found in CocoaPodsVerification/Pods/DeviceKit/Source/Device.generated.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

        Severity
        Category
        Status
        Source
        Language