philips-software/cogito

View on GitHub

Showing 31 of 119 total issues

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

  render () {
    return (
      <WithStore
        selector={state => ({
          channelId: state.userData.channelId,
Severity: Major
Found in workspaces/demo-app/src/app/Main.js - About 3 hrs to fix

    Function reducer has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const reducer = (state = {}, action) => {
      switch (action.type) {
        case 'ACCOUNTS_FETCHING_IN_PROGRESS':
          return {
            ...state,
    Severity: Major
    Found in workspaces/demo-app/src/app-events/reducer.js - About 2 hrs to fix

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

        checkArguments (telepath, tag, cryptoMaterial) {
          let errorMessage
          if (!telepath) {
            errorMessage = 'Telepath Channel'
          }
      Severity: Minor
      Found in workspaces/cogito-encryption/source/CogitoStreamDecoder.js - 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 execute has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          func execute() {
              let storyBoard = UIStoryboard(name: "SignTransaction", bundle: nil)
              // swiftlint:disable force_cast
              let viewController = storyBoard.instantiateInitialViewController() as! UINavigationController
              let explanationViewController = viewController.topViewController! as! ExplanationViewController

        Function FileStreamReaderWorkerScript has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          Function reducer has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const reducer = (state = initialState, action) => {
            switch (action.type) {
              case 'SET_USER_ACCOUNT':
                return {
                  ...state,
          Severity: Minor
          Found in workspaces/demo-app/src/user-data/reducer.js - About 1 hr to fix

            Function attestationsReducer has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            func attestationsReducer(action: Action, state: AttestationsState?) -> AttestationsState {
                var state = state ?? initialAttestationsState
                switch action {
                case let action as OpenIDAttestationActions.Pending:
                    state.open[action.nonce] = AttestationInProgress(

              Function Finish has 34 lines of code (exceeds 25 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

                Function diamondReducer has 33 lines of code (exceeds 25 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 1 hr to fix

                  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

                    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,

                      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

                            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

                            Function appState has 7 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            func appState(keyStore: KeyStoreState = initialKeyStoreState,
                                          createIdentity: CreateIdentityState = initialCreateIdentityState,
                                          diamond: DiamondState = initialDiamondState,
                                          telepath: TelepathState = initialTelepathState,
                                          attestations: AttestationsState = initialAttestationsState,
                            Severity: Major
                            Found in workspaces/cogito-ios-app/CogitoTests/AppStateHelper.swift - About 50 mins to fix

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

                                checkParams (params) {
                                  let errorMessage
                              
                                  if (!params) {
                                    errorMessage = '{ file: File, callback: (chunk: Uint8Array) => Void }'
                              Severity: Minor
                              Found in workspaces/demo-app/src/services/file-reader/FileStreamReader.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 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

                              Severity
                              Category
                              Status
                              Source
                              Language