rahulkapoor90/VITacademics-Enhancement-Suite

View on GitHub
Extension for chrome/scripts/timeTable/html2canvas.js

Summary

Maintainability
F
6 mos
Test Coverage

File html2canvas.js has 2470 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
  html2canvas 0.4.1 <http://html2canvas.hertzen.com>
  Copyright (c) 2013 Niklas von Hertzen

  Released under MIT License
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 6 days to fix

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

_html2canvas.Parse = function (images, options, cb) {
  window.scroll(0,0);

  var element = (( options.elements === undefined ) ? document.body : options.elements[0]), // select body by default
  numDraws = 0,
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 5 days to fix

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

_html2canvas.Preload = function( options ) {

  var images = {
    numLoaded: 0,   // also failed are counted here
    numFailed: 0,
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 day to fix

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

  Generate.parseGradient = function(css, bounds) {
    var gradient, i, len = reGradients.length, m1, stop, m2, m2Len, step, m3, tl,tr,br,bl;

    for(i = 0; i < len; i+=1){
      m1 = css.match(reGradients[i]);
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 day to fix

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

function h2cRenderContext(width, height) {
  var storage = [];
  return {
    storage: storage,
    width: width,
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 4 hrs to fix

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

_html2canvas.Renderer.Canvas = function(options) {
  options = options || {};

  var doc = document,
  safeImages = [],
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 4 hrs to fix

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

_html2canvas.Renderer = function(parseQueue, options){
  function sortZindex(a, b) {
    if (a === 'children') {
      return -1;
    } else if (b === 'children') {
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 3 hrs to fix

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

_html2canvas.Util.parseBackgroundImage = function (value) {
    var whitespace = ' \r\n\t',
        method, definition, prefix, prefix_i, block, results = [],
        c, mode = 0, numParen = 0, quote, args;

Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 3 hrs to fix

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

  function parseBorders(element, bounds, borders){
    var x = bounds.left,
    y = bounds.top,
    width = bounds.width,
    height = bounds.height,
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 2 hrs to fix

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

  function calculateCurvePoints(bounds, borderRadius, borders) {

    var x = bounds.left,
    y = bounds.top,
    width = bounds.width,
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 2 hrs to fix

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

  function createRenderQueue(parseQueue) {
    var queue = [],
    rootContext;

    rootContext = (function buildStackingContext(rootNode) {
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 2 hrs to fix

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

  function getCurvePoints(x, y, r1, r2) {
    var kappa = 4 * ((Math.sqrt(2) - 1) / 3);
    var ox = (r1) * kappa, // control point offset horizontal
    oy = (r2) * kappa, // control point offset vertical
    xm = x + r1, // x-middle
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 2 hrs to fix

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

window.html2canvas = function(elements, opts) {
  elements = (elements.length) ? elements : [elements];
  var queue,
  canvas,
  options = {
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 2 hrs to fix

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

  function renderElement(element, parentStack, ignoreBackground) {
    var transform = getTransform(element, parentStack),
    bounds = getBounds(element, transform),
    image,
    stack = createStack(element, parentStack, bounds, transform),
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 2 hrs to fix

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

_html2canvas.Util.Support = function (options, doc) {

  function supportSVGRendering() {
    var img = new Image(),
    canvas = doc.createElement("canvas"),
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 2 hrs to fix

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

  function addPseudoElements(el) {
    // These are done in discrete steps to prevent a relayout loop caused by addClass() invalidating
    // layouts & getPseudoElement calling getComputedStyle.
    var jobs = [], classes = [];
    getPseudoElementClasses();
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 2 hrs to fix

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

_html2canvas.Util.Font = (function () {

  var fontData = {};

  return function(font, fontSize, doc) {
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 hr to fix

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

  Generate.Gradient = function(src, bounds) {
    if(bounds.width === 0 || bounds.height === 0) {
      return;
    }

Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 hr to fix

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

    drawShape: function() {

      var shape = [];

      storage.push({
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 hr to fix

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

    cleanupDOM: function(cause) {
      var img, src;
      if (!images.cleanupDone) {
        if (cause && typeof cause === "string") {
          Util.log("html2canvas: Cleanup because: " + cause);
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 hr to fix

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

  function proxyGetImage(url, img, imageObj){
    var callback_name,
    scriptUrl = options.proxy,
    script;

Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 hr to fix

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

  function renderText(el, textNode, stack) {
    var ctx = stack.ctx,
    color = getCSS(el, "color"),
    textDecoration = getCSS(el, "textDecoration"),
    textAlign = getCSS(el, "textAlign"),
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 hr to fix

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

    loadImage: function( src ) {
      var img, imageObj;
      if ( src && images[src] === undefined ) {
        img = new Image();
        if ( src.match(/data:image\/.*;base64,/i) ) {
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 hr to fix

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

  function renderItem(ctx, item) {
    switch(item.type){
      case "variable":
        ctx[item.name] = item['arguments'];
        break;
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 hr to fix

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

  function renderFormValue (el, bounds, stack){

    var valueWrap = doc.createElement('valuewrap'),
    cssPropertyArray = ['lineHeight','textAlign','fontFamily','color','fontSize','paddingLeft','paddingTop','width','height','border','borderLeftWidth','borderTopWidth'],
    textValue,
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 hr to fix

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

  function renderBackgroundRepeating(el, bounds, ctx, image, imageIndex) {
    var backgroundSize = Util.BackgroundSize(el, bounds, image, imageIndex),
    backgroundPosition = Util.BackgroundPosition(el, bounds, image, imageIndex, backgroundSize),
    backgroundRepeat = Util.BackgroundRepeat(el, imageIndex);

Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 hr to fix

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

_html2canvas.Util.Children = function( elem ) {
  var children;
  try {
    children = (elem.nodeName && elem.nodeName.toUpperCase() === "IFRAME") ? elem.contentDocument || elem.contentWindow.document : (function(array) {
      var ret = [];
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 hr to fix

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

    rootContext = (function buildStackingContext(rootNode) {
      var rootContext = {};
      function insert(context, node, specialParent) {
        var zi = (node.zIndex.zindex === 'auto') ? 0 : Number(node.zIndex.zindex),
        contextForChildren = context, // the stacking context for children
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 hr to fix

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

    function sortZ(context) {
      Object.keys(context).sort(sortZindex).forEach(function(zi) {
        var nonPositioned = [],
        floated = [],
        positioned = [],
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 hr to fix

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

  function setImageLoadHandlers(img, imageObj) {
    img.onload = function() {
      if ( imageObj.timer !== undefined ) {
        // CORS succeeded
        window.clearTimeout( imageObj.timer );
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 hr to fix

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

  function bezierCurve(start, startControl, endControl, end) {

    var lerp = function (a, b, t) {
      return {
        x:a.x + (b.x - a.x) * t,
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 hr to fix

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

  function getPseudoElement(el, which) {
    var elStyle = window.getComputedStyle(el, which);
    var parentStyle = window.getComputedStyle(el);
    // If no content attribute is present, the pseudo element is hidden,
    // or the parent has a content property equal to the content on the pseudo element,
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 hr to fix

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

  function parseChildren(element, stack, cb) {
    var children = Util.Children(element);
    // After all nodes have processed, finished() will call the cb.
    // We add one and kick it off so this will still work when children.length === 0.
    // Note that unless async is true, this will happen synchronously, just will callbacks.
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 hr to fix

Function backgroundRepeatShape has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

  function backgroundRepeatShape(ctx, image, backgroundPosition, bounds, left, top, width, height) {
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 1 hr to fix

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

  function parseCorner(borderArgs, radius1, radius2, corner1, corner2, x, y) {
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 50 mins to fix

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

  function drawSide(borderData, radius1, radius2, outer1, inner1, outer2, inner2) {
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 50 mins to fix

Avoid deeply nested control flow statements.
Open

              if(m3[1] === 'to') {
                stop = 1.0;
              }
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

              if(m3[2]){
                stop = parseFloat(m3[2]);
                if(m3[3] === '%'){
                  stop /= 100;
                } else { // px - stupid opera
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

              if (img.script && img.script.parentNode) {
                img.script.setAttribute("src", "about:blank");  // try to cancel running request
                img.script.parentNode.removeChild(img.script);
              }
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 45 mins to fix

Function renderRect has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  function renderRect (ctx, x, y, w, h, bgcolor) {
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

              if(m3[1] === 'from') {
                stop = 0.0;
              }
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

              if(m3[2]){
                stop = parseFloat(m3[2]);
                if(m3[3] === '%'){
                  stop /= 100;
                } else { // px - stupid opera
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                if(m2[0] === 'circle'){
                  gradient.rx = gradient.ry = Math.min(
                    gradient.cx,
                    gradient.cy,
                    gradient.x1 - gradient.cx,
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

              if(m3[2]){
                stop = parseFloat(m3[2]);
                if(m3[3]){ // percentage
                  stop /= 100;
                }
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                if(m2[0] === 'circle'){
                  gradient.rx = gradient.ry = Math.max(
                    gradient.cx,
                    gradient.cy,
                    gradient.x1 - gradient.cx,
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

              switch(m2[i]) {
                case 'top':
                  gradient.y0 = 0;
                  gradient.y1 = bounds.height;
                  break;
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 45 mins to fix

Consider simplifying this complex logical expression.
Open

    if(!elStyle || !elStyle.content || elStyle.content === "none" || elStyle.content === "-moz-alt-content" ||
       elStyle.display === "none" || parentStyle.content === elStyle.content) {
      return;
    }
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 40 mins to fix

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

  function getTextBounds(state, text, textDecoration, isLast, transform) {
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 35 mins to fix

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

  function getBorderClip(element, borderPoints, borders, radius, bounds) {
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 35 mins to fix

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

  function renderBackgroundRepeating(el, bounds, ctx, image, imageIndex) {
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 35 mins to fix

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

_html2canvas.Util.BackgroundPosition = function(element, bounds, image, imageIndex, backgroundSize ) {
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 35 mins to fix

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

  function renderTextDecoration(ctx, text_decoration, bounds, metrics, color) {
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 35 mins to fix

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

  function renderImage(ctx, element, image, bounds, borders) {
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 35 mins to fix

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

_html2canvas.Util.resizeBounds = function( current_width, current_height, target_width, target_height, stretch_mode ){
Severity: Minor
Found in Extension for chrome/scripts/timeTable/html2canvas.js - About 35 mins to fix

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

(function(window, document, undefined){

//"use strict";

var _html2canvas = {},
Severity: Major
Found in Extension for chrome/scripts/timeTable/html2canvas.js and 2 other locations - About 5 mos to fix
Extension for Edge/scripts/timeTable/html2canvas.js on lines 8..3010
Extension for Firefox/scripts/timeTable/html2canvas.js on lines 8..3010

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

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