Verkehrsministerium/kraftfahrstrasse

View on GitHub

Showing 47 of 47 total issues

File Connection.ts has 338 lines of code (exceeds 250 allowed). Consider refactoring.
Open


import { CallOptions, ECallKillMode } from '../types/messages/CallMessage';
import { HelloMessageDetails, WampHelloMessage } from '../types/messages/HelloMessage';
import { EWampMessageID, WampDict, WampID, WampList, WampURI } from '../types/messages/MessageTypes';
import { PublishOptions } from '../types/messages/PublishMessage';
Severity: Minor
Found in src/generic/Connection.ts - About 4 hrs to fix

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

      private processSessionMessage(msg: WampMessage): void {
        if (!this.transport) {
          return;
        }
        this.state.update([EMessageDirection.RECEIVED, msg[0]]);
    Severity: Major
    Found in src/generic/Connection.ts - About 3 hrs to fix

      Function onMessage has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

        protected onMessage(msg: WampMessage): boolean {
          let [handled, success, error] = this.regs.Handle(msg);
          if (handled) {
            if (!success) {
              this.violator(error);
      Severity: Minor
      Found in src/generic/Callee.ts - About 2 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

      File Callee.ts has 285 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { Logger } from '../logging/Logger';
      import { CallHandler, CallResult, IRegistration, LogLevel } from '../types/Connection';
      
      import { InvocationDetails, WampYieldMessage } from '../types/messages/CallMessage';
      import { EWampMessageID, WampDict, WampID, WampList, WampURI } from '../types/messages/MessageTypes';
      Severity: Minor
      Found in src/generic/Callee.ts - About 2 hrs to fix

        Function onMessage has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          protected onMessage(msg: WampMessage): boolean {
            let [handled, success, error] = this.regs.Handle(msg);
            if (handled) {
              if (!success) {
                this.violator(error);
        Severity: Major
        Found in src/generic/Callee.ts - About 2 hrs to fix

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

            public Open(endpoint: string, cb: (ev: TransportEvent) => void) {
              if (!!this.webSocket) {
                cb({
                  type: ETransportEventType.ERROR,
                  error: 'Transport already opened!',
          Severity: Major
          Found in src/transport/WebSocketTransport.ts - About 2 hrs to fix

            Function main has 51 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const main = async () => {
              await connection.Open();
              const sub = await connection.Subscribe('foo.baz', (args, kwargs, details) => {
                console.log('EVENT:', args, kwargs, details.publisher);
              }, {});
            Severity: Major
            Found in example/index.ts - About 2 hrs to fix

              Function onMessage has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                protected onMessage(msg: WampMessage): boolean {
                  if (msg[0] === EWampMessageID.ERROR && msg[1] === EWampMessageID.CALL) {
                    const callid = msg[2];
                    this.logger.log(LogLevel.WARNING, `ID: ${callid}, Received Error for Call: ${msg[4]}`);
              
              
              Severity: Minor
              Found in src/generic/Caller.ts - About 1 hr to fix

                Function onMessage has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                  protected onMessage(msg: WampMessage): boolean {
                    if (msg[0] === EWampMessageID.ERROR && msg[1] === EWampMessageID.CALL) {
                      const callid = msg[2];
                      this.logger.log(LogLevel.WARNING, `ID: ${callid}, Received Error for Call: ${msg[4]}`);
                
                
                Severity: Minor
                Found in src/generic/Caller.ts - 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 constructor has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  constructor() {
                    const transitions = new Map<EConnectionState, StateTransitionFunction<EConnectionState, TConnectionArgs>>();
                    transitions.set(EConnectionState.CLOSED, ([msgDir, msgId]) => {
                      if (msgId === EWampMessageID.HELLO && msgDir === EMessageDirection.SENT) {
                        return EConnectionState.ETABLISHING;
                Severity: Minor
                Found in src/generic/ConnectionStateMachine.ts - About 1 hr to fix

                  Function onHandlerResult has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                    private async onHandlerResult(res: CallResult<WampList, WampDict>): Promise<void> {
                      if (!res.nextResult || this.progress) {
                        const yieldmsg: WampYieldMessage = [
                          EWampMessageID.YIELD,
                          this.callid,
                  Severity: Minor
                  Found in src/generic/Callee.ts - 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 handleTransportEvent has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                    private handleTransportEvent(event: TransportEvent): void {
                      switch (event.type) {
                        case ETransportEventType.OPEN: {
                          this.sendHello();
                          break;
                  Severity: Minor
                  Found in src/generic/Connection.ts - 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 handleTransportEvent has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    private handleTransportEvent(event: TransportEvent): void {
                      switch (event.type) {
                        case ETransportEventType.OPEN: {
                          this.sendHello();
                          break;
                  Severity: Minor
                  Found in src/generic/Connection.ts - About 1 hr to fix

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

                        transitions.set(EConnectionState.CHALLENGING, ([msgDir, msgId]) => {
                          if (msgId === EWampMessageID.AUTHENTICATE && msgDir === EMessageDirection.SENT) {
                            return EConnectionState.AUTHENTICATING;
                          }
                          return EConnectionState.ERROR;
                    Severity: Major
                    Found in src/generic/ConnectionStateMachine.ts and 2 other locations - About 1 hr to fix
                    src/generic/ConnectionStateMachine.ts on lines 24..29
                    src/generic/ConnectionStateMachine.ts on lines 61..66

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

                    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

                        transitions.set(EConnectionState.AUTHENTICATING, ([msgDir, msgId]) => {
                          if (msgId === EWampMessageID.WELCOME && msgDir === EMessageDirection.RECEIVED) {
                            return EConnectionState.ESTABLISHED;
                          }
                          return EConnectionState.ERROR;
                    Severity: Major
                    Found in src/generic/ConnectionStateMachine.ts and 2 other locations - About 1 hr to fix
                    src/generic/ConnectionStateMachine.ts on lines 24..29
                    src/generic/ConnectionStateMachine.ts on lines 54..59

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

                    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

                        transitions.set(EConnectionState.CLOSED, ([msgDir, msgId]) => {
                          if (msgId === EWampMessageID.HELLO && msgDir === EMessageDirection.SENT) {
                            return EConnectionState.ETABLISHING;
                          }
                          return EConnectionState.ERROR;
                    Severity: Major
                    Found in src/generic/ConnectionStateMachine.ts and 2 other locations - About 1 hr to fix
                    src/generic/ConnectionStateMachine.ts on lines 54..59
                    src/generic/ConnectionStateMachine.ts on lines 61..66

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

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

                      public Handle(msg: WampMessage): [boolean, boolean, string] {
                        if (this.closed) {
                          return [false, true, ''];
                        }
                        if (msg[0] === this.successMsg) {
                    Severity: Minor
                    Found in src/util/map.ts - 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 Publish has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      public async Publish<
                        A extends WampList,
                        K extends WampDict
                        >(topic: WampURI, args?: A, kwArgs?: K, options?: PublishOptions): Promise<IPublication> {
                        if (this.closed) {
                    Severity: Minor
                    Found in src/generic/Publisher.ts - About 1 hr to fix

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

                        public async Subscribe<
                          A extends WampList,
                          K extends WampDict
                          >(topic: WampURI, handler: EventHandler<A, K>, options?: SubscribeOptions): Promise<ISubscription> {
                          if (this.closed) {
                      Severity: Minor
                      Found in src/generic/Subscriber.ts - About 1 hr to fix

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

                          protected onMessage(msg: WampMessage): boolean {
                            let [handled, success, error] = this.subs.Handle(msg);
                            if (handled) {
                              if (!success) {
                                this.violator(error);
                        Severity: Minor
                        Found in src/generic/Subscriber.ts - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language