philips-software/cogito

View on GitHub

Showing 31 of 119 total issues

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

function checkJsonRpcStructure (structure, isNotification) {
  if (structure.jsonrpc !== '2.0') {
    throw new Error('request is not a JSON-RPC 2.0 object')
  }
  if (isNotification) {
Severity: Minor
Found in workspaces/telepath-js/source/json-rpc-channel.js - 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 GetAttestations has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    static func GetAttestations(requestId: JsonRpcId,
                                applicationName: String,
                                oidcRealmUrl: String,
                                subject: String?,
                                channel: TelepathChannel) -> Thunk<AppState> {

    Function StartAttestation has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            for identity: Identity,
            requestId: JsonRpcId,
            oidcRealmUrl: URL,
            subject: String?,
            requestedOnChannel channelId: ChannelID? = nil) -> Thunk<AppState> {

      Function send has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          static func send(requestId: JsonRpcId,
                           idToken: String,
                           dispatch: DispatchFunction,
                           state: AppState,
                           on channel: TelepathChannel) {

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

          async attempt () {
            while (this.waiting[0] && this.waiting[0].expiry <= this.currentAttempt) {
              this.waiting.shift().resolve(null)
            }
            if (this.waiting.length === 0) {
        Severity: Minor
        Found in workspaces/telepath-js/source/poller.js - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

        func diamondReducer(action: Action, state: DiamondState?) -> DiamondState {
            var state = state ?? initialDiamondState
            switch action {
            case let createFacet as DiamondActions.CreateFacet:
                var newFacets = state.facets
        Severity: Minor
        Found in workspaces/cogito-ios-app/Cogito/Diamond/DiamondReducer.swift - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

            func bindToViewModel() {
                self.tableView.dataSource = nil
        
                let dataSource = RxTableViewSectionedReloadDataSource<ViewModel.SectionModel>(
                    configureCell: { dataSource, table, indexPath, _ 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 getWeb3 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        const getWeb3 = () =>
          new Promise((resolve) => {
            if (process.env.REACT_APP_USE_INJECTED_WEB3 === 'YES') {
              console.log('will try to use injected web3 if possible')
              /* istanbul ignore else  */
        Severity: Minor
        Found in workspaces/cogito-ethereum/source/getWeb3.js - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

            public func receive(completion: @escaping (String?, Error?) -> Void) {
                queuing.receive(queueId: receivingQueue) { data, error in
                    guard error == nil else {
                        completion(nil, Failure.receivingFailed(cause: error!))
                        return
        Severity: Minor
        Found in workspaces/telepath-ios/Telepath/SecureChannel.swift - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

        const FileStreamReaderWorkerScript = () => {
          const FileStreamReaderWorker = function (file, callback) {
            // eslint-disable-next-line no-undef
            this.reader = new FileReaderSync()
            this.start = 0

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

          checkArguments (jsonWebKey) {
            let errorMessage
            if (!jsonWebKey) {
              errorMessage = 'iOS Public key in JSON Web Key format'
            } else {
        Severity: Minor
        Found in workspaces/cogito-encryption/source/CogitoStreamEncoder.js - 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