zk/src/main/resources/web/js/zk/mount.ts

Summary

Maintainability
F
5 days
Test Coverage

File mount.ts has 742 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* mount.js

    Purpose:

    Description:
Severity: Major
Found in zk/src/main/resources/web/js/zk/mount.ts - About 1 day to fix

    Function create has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

    function create(parent: zk.Widget | undefined, wi: WidgetInfo, ignoreDom?: boolean): zk.Widget {
        let nm;
        var wgt: zk.Widget, stub: boolean,
            type = wi[0],
            uuid = wi[1],
    Severity: Minor
    Found in zk/src/main/resources/web/js/zk/mount.ts - About 5 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 mtBL0 has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    function mtBL0(): void {
        for (; ;) {
            if (_crInfBL0.length)
                return; //another page started
    
    
    Severity: Minor
    Found in zk/src/main/resources/web/js/zk/mount.ts - About 4 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 create has 75 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function create(parent: zk.Widget | undefined, wi: WidgetInfo, ignoreDom?: boolean): zk.Widget {
        let nm;
        var wgt: zk.Widget, stub: boolean,
            type = wi[0],
            uuid = wi[1],
    Severity: Major
    Found in zk/src/main/resources/web/js/zk/mount.ts - About 3 hrs to fix

      Function zkx has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          export function zkx(wi?: WidgetInfo, extra?: ExtraInfo, aucmds?: AuCmds, js?: string): void { //extra is either delay (BL) or [stub, filter] (AU)
              zk.mounting = true;
      
              try {
                  if (js) jq.globalEval(js);
      Severity: Minor
      Found in zk/src/main/resources/web/js/zk/mount.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

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

          export function zkx(wi?: WidgetInfo, extra?: ExtraInfo, aucmds?: AuCmds, js?: string): void { //extra is either delay (BL) or [stub, filter] (AU)
              zk.mounting = true;
      
              try {
                  if (js) jq.globalEval(js);
      Severity: Minor
      Found in zk/src/main/resources/web/js/zk/mount.ts - About 1 hr to fix

        Function zkdt has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            export function zkdt(dtid?: string, contextURI?: string, updateURI?: string, resourceURI?: string, reqURI?: string): zk.Desktop {
                var dt = zk.Desktop.$(dtid);
                if (dt == null) {
                    dt = new zk.Desktop(dtid!, contextURI, updateURI, resourceURI, reqURI);
                    if (zk.pfmeter) zAu._pfrecv(dt, dtid);
        Severity: Minor
        Found in zk/src/main/resources/web/js/zk/mount.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 mtAU has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        function mtAU(): void {
            for (; ;) {
                if (zk.loading) {
                    zk.afterLoad(mtAU);
                    return;
        Severity: Minor
        Found in zk/src/main/resources/web/js/zk/mount.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 mtBL0 has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function mtBL0(): void {
            for (; ;) {
                if (_crInfBL0.length)
                    return; //another page started
        
        
        Severity: Minor
        Found in zk/src/main/resources/web/js/zk/mount.ts - About 1 hr to fix

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

              export function zkpb(pguid: string, dtid: string, contextURI: string, updateURI: string, resourceURI: string, reqURI: string, props: Record<string, string>): void {
          Severity: Major
          Found in zk/src/main/resources/web/js/zk/mount.ts - About 50 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if (!jq('#zk_proc').length) //B65-ZK-1431: check if progressbox exists
                                    zUtl.progressbox('zk_proc', window.msgzk ? msgzk.PLEASE_WAIT : 'Processing...', true);
            Severity: Major
            Found in zk/src/main/resources/web/js/zk/mount.ts - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if (_afterKD(w, wevt))
                                          return;
              Severity: Major
              Found in zk/src/main/resources/web/js/zk/mount.ts - About 45 mins to fix

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

                function mtBL(): void {
                    for (; ;) {
                        if (zk.loading) {
                            zk.afterLoad(mtBL); //later
                            return;
                Severity: Minor
                Found in zk/src/main/resources/web/js/zk/mount.ts - 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 mtBL1 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                function mtBL1(): void {
                    if (_crInfBL0.length || _crInfBL1.length)
                        return; //another page started
                
                    zk.booted = true;
                Severity: Minor
                Found in zk/src/main/resources/web/js/zk/mount.ts - 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 zkver has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    export function zkver(ver: string, build: string, ctxURI: string, updURI: string, modVers: Record<string, string>, opts: Record<string, unknown>): void {
                Severity: Minor
                Found in zk/src/main/resources/web/js/zk/mount.ts - About 45 mins to fix

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

                      export function zkdt(dtid?: string, contextURI?: string, updateURI?: string, resourceURI?: string, reqURI?: string): zk.Desktop {
                  Severity: Minor
                  Found in zk/src/main/resources/web/js/zk/mount.ts - About 35 mins to fix

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

                    export function afterMount(fn?: () => void, delay?: number): boolean { //part of zk
                        if (fn) {
                            if (!jq.isReady)
                                jq(function () {
                                    zk.afterMount(fn);
                    Severity: Minor
                    Found in zk/src/main/resources/web/js/zk/mount.ts - 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 mountpkg has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function mountpkg(infs: InfoBeforeLoad[]): void {
                        var types: Record<string, zk.Desktop> = {};
                        for (var j = infs.length; j--;) {
                            var inf = infs[j];
                            if (!inf.pked) { //mountpkg might be called multiple times before mount()
                    Severity: Minor
                    Found in zk/src/main/resources/web/js/zk/mount.ts - 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

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

                            .keypress(function (evt) {
                                var wgt = zk.keyCapture;
                                if (!wgt) wgt = Widget.$(evt, {child: true});
                                _doEvt(new zk.Event(wgt, 'onKeyPress', evt.keyData(), undefined, evt));
                            })
                    Severity: Major
                    Found in zk/src/main/resources/web/js/zk/mount.ts and 1 other location - About 1 hr to fix
                    zk/src/main/resources/web/js/zk/mount.ts on lines 779..783

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

                    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

                            .on('paste', function (evt: JQuery.TriggeredEvent & {keyData()}) {
                                var wgt = zk.keyCapture;
                                if (!wgt) wgt = Widget.$(evt, {child: true});
                                _doEvt(new zk.Event(wgt, 'onPaste', evt.keyData(), undefined, evt));
                            })
                    Severity: Major
                    Found in zk/src/main/resources/web/js/zk/mount.ts and 1 other location - About 1 hr to fix
                    zk/src/main/resources/web/js/zk/mount.ts on lines 774..778

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

                    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

                                if (wgt && evt.which == 1) {
                                    var wevt = new zk.Event(wgt, 'onDoubleClick', evt.mouseData(), {}, evt);
                                    _doEvt(wevt);
                                    if (wevt.domStopped)
                                        return false;
                    Severity: Minor
                    Found in zk/src/main/resources/web/js/zk/mount.ts and 1 other location - About 40 mins to fix
                    zk/src/main/resources/web/js/zk/mount.ts on lines 792..797

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

                    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

                                if (wgt) {
                                    var wevt = new zk.Event(wgt, 'onRightClick', evt.mouseData(), {}, evt);
                                    _doEvt(wevt);
                                    if (wevt.domStopped)
                                        return false;
                    Severity: Minor
                    Found in zk/src/main/resources/web/js/zk/mount.ts and 1 other location - About 40 mins to fix
                    zk/src/main/resources/web/js/zk/mount.ts on lines 865..870

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

                    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

                                _doEvt(new zk.Event(Widget.$(evt, {child: true}), 'onMouseOut', evt.mouseData(), {ignorable: true}, evt));
                    Severity: Minor
                    Found in zk/src/main/resources/web/js/zk/mount.ts and 1 other location - About 35 mins to fix
                    zk/src/main/resources/web/js/zk/mount.ts on lines 837..837

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

                    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

                                _doEvt(new zk.Event(Widget.$(evt, {child: true}), 'onMouseOver', evt.mouseData(), {ignorable: true}, evt));
                    Severity: Minor
                    Found in zk/src/main/resources/web/js/zk/mount.ts and 1 other location - About 35 mins to fix
                    zk/src/main/resources/web/js/zk/mount.ts on lines 840..840

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

                    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

                    There are no issues that match your filters.

                    Category
                    Status