philips-software/cogito

View on GitHub

Showing 102 of 119 total issues

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

enum SignTransactionError: Int, TelepathError {
    case invalidTransaction = 1000
    case signingFailed
    case userRejected
    case unknownIdentity
workspaces/cogito-ios-app/Cogito/Telepath/TelepathError.swift on lines 24..40
workspaces/cogito-ios-app/Cogito/ValueStore service/ValueStoreError.swift on lines 1..17

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

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

enum AttestationError: Int, TelepathError {
    case invalidRealmUrl = 2000
    case invalidConfiguration
    case userDeniedAccess
    case userCancelledLogin
workspaces/cogito-ios-app/Cogito/Telepath/TelepathError.swift on lines 6..22
workspaces/cogito-ios-app/Cogito/ValueStore service/ValueStoreError.swift on lines 1..17

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

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

    func withOpenIdConfiguration(completion: @escaping ([String: Any]?, String?) -> Void) {
        let configUrl = oidcRealmUrl
            .appendingPathComponent(".well-known", isDirectory: true)
            .appendingPathComponent("openid-configuration", isDirectory: false)
        let task = URLSession.shared.dataTask(with: configUrl) { data, _, error in

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

    private func transitionToSelectedFacet() {
        connection.disconnect()

        let text = "Who am I?"
        var endIndex = text.endIndex

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

    extension JsonRpcRequest: Equatable {
        static func == (lhs: JsonRpcRequest, rhs: JsonRpcRequest) -> Bool {
            return
                lhs.id == rhs.id &&
                lhs.method == rhs.method &&
    workspaces/cogito-ios-app/Cogito/Key store/KeyStore.swift on lines 225..229

    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

    extension KeyStore: Equatable {
        static func == (lhs: KeyStore, rhs: KeyStore) -> Bool {
            return lhs.name == rhs.name && lhs.scryptN == rhs.scryptN && lhs.scryptP == rhs.scryptP
        }
    }
    Severity: Major
    Found in workspaces/cogito-ios-app/Cogito/Key store/KeyStore.swift and 1 other location - About 1 hr to fix
    workspaces/cogito-ios-app/Cogito/Telepath/JsonRpcRequest.swift on lines 32..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 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

    Function build has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        func build() -> GetAttestations {
            guard let url = URL(string: oidcRealmUrlString) else {
                return GetAttestationsInvalid(requestId: requestId,
                                              error: .invalidRealmUrl,
                                              dispatch: dispatch,

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

          static func Send(id: JsonRpcId,
                           result: [Any],
                           on channel: TelepathChannel) -> Thunk<AppState> {
              return Thunk { dispatch, _ in
                  let response = JSON([
      workspaces/cogito-ios-app/Cogito/Telepath/TelepathActions.swift on lines 117..128

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

      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

          static func Send(id: JsonRpcId,
                           result: [String: Any],
                           on channel: TelepathChannel) -> Thunk<AppState> {
              return Thunk { dispatch, _ in
                  let response = JSON([
      workspaces/cogito-ios-app/Cogito/Telepath/TelepathActions.swift on lines 131..142

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

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

          static func Finish(params: [String: String]) -> Thunk<AppState> {
              return Thunk { dispatch, getState in
                  guard let idToken = params["id_token"] else {
                      dispatch(FinishRejected(nonce: nil, error: "id token missing"))
                      return

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

          func bindToViewModel() {
              self.tableView.dataSource = nil
      
              let dataSource = RxTableViewSectionedReloadDataSource<ViewModel.SectionModel>(
                  configureCell: { dataSource, table, indexPath, _ in

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

            override func viewDidLoad() {
                super.viewDidLoad()
        
                self.tableView.dataSource = nil
                dataSource = RxTableViewSectionedAnimatedDataSource(

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

            render () {
              const { children, title, subtitle, documentation, routeProps } = this.props
          
              return (
                <TheGrid>
          Severity: Minor
          Found in workspaces/demo-app/src/components/ui/demo/Demo.js - About 1 hr to fix

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

            const getProviderURL = () => {
              if (process.env.NODE_ENV === 'production') {
                return process.env.REACT_APP_WEB3_PROVIDER_URL_PRODUCTION
              }
            
            
            Severity: Major
            Found in workspaces/cogito-ethereum/source/getWeb3.js and 1 other location - About 1 hr to fix
            workspaces/demo-app/src/components/cogito-contract/actions.js on lines 8..14

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

            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

            private func takeData(from txDict: [String: Any], key: String) -> Data? {
                guard let dataString = txDict[key] as? String,
                      let data = Data(fromHex: dataString) else {
                    return nil
                }
            Severity: Major
            Found in workspaces/cogito-ios-app/Cogito/Geth/Transaction.swift and 1 other location - About 1 hr to fix
            workspaces/cogito-ios-app/Cogito/Geth/Transaction.swift on lines 61..67

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

            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

            private func takeAddress(from txDict: [String: Any], key: String) -> Address? {
                guard let addressString = txDict[key] as? String,
                      let address = Address(fromHex: addressString) else {
                    return nil
                }
            Severity: Major
            Found in workspaces/cogito-ios-app/Cogito/Geth/Transaction.swift and 1 other location - About 1 hr to fix
            workspaces/cogito-ios-app/Cogito/Geth/Transaction.swift on lines 79..85

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

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

            extension AlertAction: Equatable {
                static func == (lhs: AlertAction, rhs: AlertAction) -> Bool {
                    return lhs.title == rhs.title && lhs.style == rhs.style
                }
            }
            workspaces/cogito-ios-app/Cogito/Diamond/DiamondState.swift on lines 27..31
            workspaces/cogito-ios-app/Cogito/Telepath/TelepathState.swift on lines 38..43

            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

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

            extension DiamondState: Equatable {
                static func == (lhs: DiamondState, rhs: DiamondState) -> Bool {
                    return lhs.facets == rhs.facets && lhs.selectedFacetId == rhs.selectedFacetId
                }
            }
            Severity: Major
            Found in workspaces/cogito-ios-app/Cogito/Diamond/DiamondState.swift and 2 other locations - About 55 mins to fix
            workspaces/cogito-ios-app/Cogito/Dialog presenter/RequestedAlert.swift on lines 39..43
            workspaces/cogito-ios-app/Cogito/Telepath/TelepathState.swift on lines 38..43

            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

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

            extension TelepathMessage: Equatable {
                static func == (lhs: TelepathMessage, rhs: TelepathMessage) -> Bool {
                    return lhs.message == rhs.message &&
                           lhs.channel == rhs.channel
                }
            Severity: Major
            Found in workspaces/cogito-ios-app/Cogito/Telepath/TelepathState.swift and 2 other locations - About 55 mins to fix
            workspaces/cogito-ios-app/Cogito/Dialog presenter/RequestedAlert.swift on lines 39..43
            workspaces/cogito-ios-app/Cogito/Diamond/DiamondState.swift on lines 27..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 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 Receive has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                static func Receive() -> Thunk<AppState> {
                    return Thunk { dispatch, getState in
                        guard let channels = getState()?.telepath.channels else { return }
                        for channel in channels.keys {
                            channel.receive { message, error in
            Severity: Minor
            Found in workspaces/cogito-ios-app/Cogito/Telepath/TelepathActions.swift - About 55 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