codenautas/js-to-html

View on GitHub

Showing 18 of 180 total issues

File js-to-html.ts has 1821 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"use strict";

var SCRIPT_IS_VOID = true;

export function setScriptIsVoid(is:boolean){
Severity: Major
Found in src/js-to-html.ts - About 4 days to fix

    html has 120 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export var html={
        defaultTitle:"",
        insecureModeEnabled:true,
        mandatoryTitle:true,
        optimizingArrange:true,
    Severity: Major
    Found in src/js-to-html.ts - About 2 days to fix

      Function toHtmlDoc has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          toHtmlDoc(opts:PrintOpts,recurseOpts:PrintRecurseOpts){
              opts = opts||{};
              var target:Html=this;
              if(!opts.incomplete){
                  var source:Html=this;
      Severity: Minor
      Found in src/js-to-html.ts - About 3 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 tagInterface.js has 283 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      
      var fs=require('fs').promises;
      
      // https://html.spec.whatwg.org/multipage/indices.html#element-interfaces
      
      Severity: Minor
      Found in generators/tagInterface.js - About 2 hrs to fix

        Function indirect has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

        function indirect(tagName:string,contentOrAttributes?:Content|object,contentIfThereAreAttributes?:Content){
            var attributes:object={};
            var content:Content=[];
            if(typeof contentOrAttributes=="object" && !(contentOrAttributes instanceof Array) ){
                if(contentOrAttributes!=null){
        Severity: Minor
        Found in src/js-to-html.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 arrange has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function arrange(element:HTMLElement|SVGElement, listOfObjects:HtmlBase|HtmlBase[]):void{
            if(!(listOfObjects instanceof Array)){
                return arrange(element, [listOfObjects]);
            }
            // @ts-ignore
        Severity: Major
        Found in src/js-to-html.ts - About 2 hrs to fix

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

              assignAttr(element:HTMLElement|SVGElement, attributesMap:any, testFirst:boolean){
                  let esto = this;
                  let attributes = attributesMap || this.attributes;
                  var tagInfo=htmlTags[this.tagName];
                  Object.keys(attributes).map(function(attr){
          Severity: Minor
          Found in src/js-to-html.ts - About 1 hr to fix

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

                toHtmlDoc(opts:PrintOpts,recurseOpts:PrintRecurseOpts){
                    opts = opts||{};
                    var target:Html=this;
                    if(!opts.incomplete){
                        var source:Html=this;
            Severity: Minor
            Found in src/js-to-html.ts - About 1 hr to fix

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

                  toHtmlText(opts?:PrintOpts, recurseOpts?:PrintRecurseOpts):string{
                      opts=opts||{};
                      recurseOpts=recurseOpts||{};
                      recurseOpts.margin=recurseOpts.margin||0;
                      var tagInfo=htmlTags[this.tagName];
              Severity: Minor
              Found in src/js-to-html.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 exports has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports = function(config) {
                config.set({
              
                  // base path that will be used to resolve all patterns (eg. files, exclude)
                  basePath: '',
              Severity: Minor
              Found in karma.conf.js - About 1 hr to fix

                Function constructor has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    constructor(directObject:DirectObject, validProperties?:ValidPropertydProperty){
                        /*jshint forin:false */
                        for(var property in validProperties){
                            /*jshint forin:true */
                            var propertyDef=validProperties[property];
                Severity: Minor
                Found in src/js-to-html.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 check has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                                {check:function(attributes){
                                    /*jshint forin:false */
                                    for(var attrName in attributes){
                                        /*jshint forin:true */
                                        var attrValue=attributes[attrName];
                Severity: Minor
                Found in src/js-to-html.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 indirect has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function indirect(tagName:string,contentOrAttributes?:Content|object,contentIfThereAreAttributes?:Content){
                    var attributes:object={};
                    var content:Content=[];
                    if(typeof contentOrAttributes=="object" && !(contentOrAttributes instanceof Array) ){
                        if(contentOrAttributes!=null){
                Severity: Minor
                Found in src/js-to-html.ts - About 1 hr to fix

                  Function check has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                                  {check:function(attributes, o){  
                                      /*jshint forin:false */
                                      for(var attrName in attributes){
                                          /*jshint forin:true */
                                          var attrInfo=htmlAttributes[attrName];
                  Severity: Minor
                  Found in src/js-to-html.ts - 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

                  Avoid deeply nested control flow statements.
                  Open

                                          if(!testFirst || element[defAttr.idl] != value){
                                              html.auditArrange?.('attr.set', true);
                                              // @ts-ignore // no le gusta indexar HTML
                                              element[defAttr.idl] = value;
                                          }
                  Severity: Major
                  Found in src/js-to-html.ts - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if(!testFirst || $on[eventName] != value[eventName]){
                                                html.auditArrange?.('attr.on', true);
                                                if(eventName in $on){
                                                    element.removeEventListener(eventName, $on[eventName])
                                                }
                    Severity: Major
                    Found in src/js-to-html.ts - About 45 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                              if(!domElement || !(
                                  domElement instanceof Text && htmlElement instanceof HtmlTextNode ||
                                  'tagName' in domElement && 'tagName' in htmlElement && domElement.tagName.toLowerCase() == htmlElement.tagName 
                              ) ){
                                  var newElement;
                      Severity: Major
                      Found in src/js-to-html.ts - About 40 mins to fix

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

                            setOrResetAttribute(element:HTMLElement|SVGElement, attr:string, valueOrNull:null|string, testFirst:boolean){
                                html.auditArrange?.('attr.mod', false);
                                if(!testFirst || valueOrNull == null && element.hasAttribute(attr) || valueOrNull != element.getAttribute(attr)){
                                    html.auditArrange?.('attr.mod', true);
                                    if(valueOrNull!=null){
                        Severity: Minor
                        Found in src/js-to-html.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

                        Severity
                        Category
                        Status
                        Source
                        Language