devlato/vectorizer

View on GitHub

Showing 80 of 80 total issues

File imagetracer_v1.2.6.ts has 1511 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
imagetracer.js version 1.2.6
Simple raster image tracer and vectorizer written in JavaScript.
andras@jankovics.net
*/
Severity: Major
Found in src/imagetracer_v1.2.6.ts - About 4 days to fix

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

    for (let pcnt = 0; pcnt < hsmp.segments.length; pcnt++) {
    const pnt = hsmp.segments[pcnt];
    if (pnt.x3 != null && options.qcpr) {
    str.push(
    `<circle cx="${pnt.x2 * options.scale}" cy="${pnt.y2 * options.scale}" r="${
    Severity: Major
    Found in src/imagetracer_v1.2.6.ts and 1 other location - About 2 days to fix
    src/imagetracer_v1.2.6.ts on lines 1541..1566

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

    for (let pcnt = 0; pcnt < smp.segments.length; pcnt++) {
    const pnt = smp.segments[pcnt];
    if (pnt.x3 != null && options.qcpr) {
    str.push(
    `<circle cx="${pnt.x2 * options.scale}" cy="${pnt.y2 * options.scale}" r="${
    Severity: Major
    Found in src/imagetracer_v1.2.6.ts and 1 other location - About 2 days to fix
    src/imagetracer_v1.2.6.ts on lines 1571..1596

    Function pathscan has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
    Open

    private pathscan(array: number[][], pathomit: number): Path[] {
    const paths: Path[] = [];
    let pacnt = 0;
    let pcnt = 0;
    let px = 0;
    Severity: Minor
    Found in src/imagetracer_v1.2.6.ts - About 1 day to fix

    Function svgpathstring has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
    Open

    svgpathstring(tracedata: TraceData, lnum: number, pathnum: number, options: Options): SVGString {
    const layer = tracedata.layers[lnum];
    const smp = layer[pathnum];
    const str: string[] = [];
     
     
    Severity: Minor
    Found in src/imagetracer_v1.2.6.ts - About 1 day to fix

    Function colorquantization has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

    private colorquantization(imageData: ImageData, options: Options): ClusteredImageData {
    const array: number[][] = [];
    let idx = 0;
    let cd: number;
    let cdl: number;
    Severity: Minor
    Found in src/imagetracer_v1.2.6.ts - About 6 hrs to fix

    Function layering has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

    private layering(ii: ClusteredImageData): number[][][] {
    // Creating layers for each indexed color in arr
    const layers: number[][][] = [];
    let val = 0;
    const ah = ii.array.length;
    Severity: Minor
    Found in src/imagetracer_v1.2.6.ts - About 6 hrs to fix

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

    svgpathstring(tracedata: TraceData, lnum: number, pathnum: number, options: Options): SVGString {
    const layer = tracedata.layers[lnum];
    const smp = layer[pathnum];
    const str: string[] = [];
     
     
    Severity: Major
    Found in src/imagetracer_v1.2.6.ts - About 5 hrs to fix

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

      (path.points[idx3].x === path.points[idx1].x &&
      path.points[idx3].x === path.points[idx2].x &&
      path.points[idx3].y === path.points[idx4].y &&
      path.points[idx3].y === path.points[idx5].y) ||
      Severity: Major
      Found in src/imagetracer_v1.2.6.ts and 1 other location - About 4 hrs to fix
      src/imagetracer_v1.2.6.ts on lines 1197..1200

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

      (path.points[idx3].y === path.points[idx1].y &&
      path.points[idx3].y === path.points[idx2].y &&
      path.points[idx3].x === path.points[idx4].x &&
      path.points[idx3].x === path.points[idx5].x)
      Severity: Major
      Found in src/imagetracer_v1.2.6.ts and 1 other location - About 4 hrs to fix
      src/imagetracer_v1.2.6.ts on lines 1193..1196

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

      palette.push({
      r: Math.floor(Math.random() * 255) as ColorComponentValue,
      g: Math.floor(Math.random() * 255) as ColorComponentValue,
      b: Math.floor(Math.random() * 255) as ColorComponentValue,
      a: Math.floor(Math.random() * 255) as ColorComponentValue,
      Severity: Major
      Found in src/imagetracer_v1.2.6.ts and 1 other location - About 4 hrs to fix
      src/imagetracer_v1.2.6.ts on lines 731..736

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

      palette[k] = {
      r: Math.floor(Math.random() * 255) as ColorComponentValue,
      g: Math.floor(Math.random() * 255) as ColorComponentValue,
      b: Math.floor(Math.random() * 255) as ColorComponentValue,
      a: Math.floor(Math.random() * 255) as ColorComponentValue,
      Severity: Major
      Found in src/imagetracer_v1.2.6.ts and 1 other location - About 4 hrs to fix
      src/imagetracer_v1.2.6.ts on lines 869..874

      ImageTracer has 34 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export default class ImageTracer {
      private readonly versionnumber = '1.2.6';
       
      // Loading an image from a URL, tracing when loaded,
      // then executing callback with the scaled svg string as argument
      Severity: Minor
      Found in src/imagetracer_v1.2.6.ts - About 4 hrs to fix

        Function blur has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

        blur(imgd: ImageData, radius: number, delta: number) {
        let i, j, k, d, idx, racc, gacc, bacc, aacc, wacc;
         
        // new ImageData
        const imgd2: ImageData = { width: imgd.width, height: imgd.height, data: new Uint8ClampedArray() };
        Severity: Minor
        Found in src/imagetracer_v1.2.6.ts - About 4 hrs to fix

        OptionsBuilder has 32 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export class OptionsBuilder {
        private options: Options;
         
        static create() {
        return new OptionsBuilder();
        Severity: Minor
        Found in src/imagetracer.ts - About 4 hrs to fix

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

          private fitseq(
          path: Path,
          ltres: number,
          qtres: number,
          seqstart: number,
          Severity: Major
          Found in src/imagetracer_v1.2.6.ts - About 3 hrs to fix

            File imagetracer.ts has 318 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /* eslint-disable @typescript-eslint/camelcase */
            import ImageTracer, {
            BlurRadius,
            ColorComponentValue,
            ColorSampling,
            Severity: Minor
            Found in src/imagetracer.ts - About 3 hrs to fix

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

              private colorquantization(imageData: ImageData, options: Options): ClusteredImageData {
              const array: number[][] = [];
              let idx = 0;
              let cd: number;
              let cdl: number;
              Severity: Major
              Found in src/imagetracer_v1.2.6.ts - About 3 hrs to fix

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

                palette.push({
                r: imageData.data[idx] as ColorComponentValue,
                g: imageData.data[idx + 1] as ColorComponentValue,
                b: imageData.data[idx + 2] as ColorComponentValue,
                a: imageData.data[idx + 3] as ColorComponentValue,
                Severity: Major
                Found in src/imagetracer_v1.2.6.ts and 1 other location - About 3 hrs to fix
                src/imagetracer_v1.2.6.ts on lines 819..824

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

                palette.push({
                r: imageData.data[idx] as ColorComponentValue,
                g: imageData.data[idx + 1] as ColorComponentValue,
                b: imageData.data[idx + 2] as ColorComponentValue,
                a: imageData.data[idx + 3] as ColorComponentValue,
                Severity: Major
                Found in src/imagetracer_v1.2.6.ts and 1 other location - About 3 hrs to fix
                src/imagetracer_v1.2.6.ts on lines 793..798
                Severity
                Category
                Status
                Source
                Language