obartra/ssim

View on GitHub

Showing 32 of 32 total issues

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

function subtract2dMx(
  { data: ref1, width, height }: Matrix,
  { data: ref2 }: Matrix
): Matrix {
  const data = new Array(ref1.length)
Severity: Major
Found in src/math.ts and 1 other location - About 7 hrs to fix
src/math.ts on lines 99..118

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

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

function add2dMx(
  { data: ref1, width, height }: Matrix,
  { data: ref2 }: Matrix
): Matrix {
  const data = new Array(ref1.length)
Severity: Major
Found in src/math.ts and 1 other location - About 7 hrs to fix
src/math.ts on lines 132..151

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

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

function divide2dMx(
  { data: ref1, width, height }: Matrix,
  { data: ref2 }: Matrix
): Matrix {
  const data = new Array(ref1.length)
Severity: Major
Found in src/math.ts and 1 other location - About 5 hrs to fix
src/math.ts on lines 330..345

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

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

function multiply2dMx(
  { data: ref1, width, height }: Matrix,
  { data: ref2 }: Matrix
): Matrix {
  const data = new Array(ref1.length)
Severity: Major
Found in src/math.ts and 1 other location - About 5 hrs to fix
src/math.ts on lines 256..271

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

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

function add2dScalar(
  { data: ref, width, height }: Matrix,
  increase: number
): Matrix {
  const data = new Array(ref.length)
Severity: Major
Found in src/math.ts and 2 other locations - About 4 hrs to fix
src/math.ts on lines 228..243
src/math.ts on lines 302..317

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

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

function multiply2dScalar(
  { data: ref, width, height }: Matrix,
  multiplier: number
): Matrix {
  const data = new Array(ref.length)
Severity: Major
Found in src/math.ts and 2 other locations - About 4 hrs to fix
src/math.ts on lines 164..179
src/math.ts on lines 228..243

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

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

function divide2dScalar(
  { data: ref, width, height }: Matrix,
  divisor: number
): Matrix {
  const data = new Array(ref.length)
Severity: Major
Found in src/math.ts and 2 other locations - About 4 hrs to fix
src/math.ts on lines 164..179
src/math.ts on lines 302..317

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

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

function fastPadding(
  A: Matrix,
  [padHeight, padWidth]: [number, number]
): Matrix {
  const width = A.width + padWidth * 2
Severity: Minor
Found in src/matlab/padarray.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

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

): Matrix {
  const num1 = add2d(multiply2d(μ12, 2), c1)
  const num2 = add2d(multiply2d(σ12, 2), c2)
  const denom1 = add2d(add2d(μ1Sq, μ2Sq), c1)
  const denom2 = add2d(add2d(σ1Sq, σ2Sq), c2)
Severity: Major
Found in src/ssim.ts and 1 other location - About 2 hrs to fix
src/originalSsim.ts on lines 61..68

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

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

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

  if (c1 > 0 && c2 > 0) {
    const num1 = add2d(multiply2d(μ12, 2), c1)
    const num2 = add2d(multiply2d(σ12, 2), c2)
    const denom1 = add2d(add2d(μ1Sq, μ2Sq), c1)
    const denom2 = add2d(add2d(σ1Sq, σ2Sq), c2)
Severity: Major
Found in src/originalSsim.ts and 1 other location - About 2 hrs to fix
src/ssim.ts on lines 126..133

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

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 fastPadding has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function fastPadding(
  A: Matrix,
  [padHeight, padWidth]: [number, number]
): Matrix {
  const width = A.width + padWidth * 2
Severity: Minor
Found in src/matlab/padarray.ts - About 1 hr to fix

    Function mxConv2 has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    function mxConv2(
      { data: ref, width: refWidth, height: refHeight }: Matrix,
      b: Matrix,
      shape: Shape = 'full'
    ): Matrix {
    Severity: Minor
    Found in src/matlab/conv2.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 weberSsim has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function weberSsim(
      pixels1: ImageMatrix,
      pixels2: ImageMatrix,
      options: Options
    ): MSSIMMatrix {
    Severity: Minor
    Found in src/weberSsim.ts - About 1 hr to fix

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

      export function add2d(A: Matrix, increase: Matrix | number): Matrix {
        if (typeof increase === 'number') {
          return add2dScalar(A, increase)
        }
        return add2dMx(A, increase)
      Severity: Major
      Found in src/math.ts and 2 other locations - About 1 hr to fix
      src/math.ts on lines 284..289
      src/math.ts on lines 359..364

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

      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

      export function divide2d(A: Matrix, divisor: Matrix | number): Matrix {
        if (typeof divisor === 'number') {
          return divide2dScalar(A, divisor)
        }
        return divide2dMx(A, divisor)
      Severity: Major
      Found in src/math.ts and 2 other locations - About 1 hr to fix
      src/math.ts on lines 192..197
      src/math.ts on lines 359..364

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

      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

      export function multiply2d(A: Matrix, multiplier: Matrix | number): Matrix {
        if (typeof multiplier === 'number') {
          return multiply2dScalar(A, multiplier)
        }
        return multiply2dMx(A, multiplier)
      Severity: Major
      Found in src/math.ts and 2 other locations - About 1 hr to fix
      src/math.ts on lines 192..197
      src/math.ts on lines 284..289

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

      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 originalSsim has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function originalSsim(
        pixels1: Matrix,
        pixels2: Matrix,
        options: Options
      ): Matrix {
      Severity: Minor
      Found in src/originalSsim.ts - About 1 hr to fix

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

          if ('k2' in options && (typeof options.k2 !== 'number' || options.k2 < 0)) {
            throw new Error(`Invalid k2 value. Default is ${defaults.k2}`)
          }
        Severity: Major
        Found in src/index.ts and 1 other location - About 1 hr to fix
        src/index.ts on lines 38..40

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

        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 ('k1' in options && (typeof options.k1 !== 'number' || options.k1 < 0)) {
            throw new Error(`Invalid k1 value. Default is ${defaults.k1}`)
          }
        Severity: Major
        Found in src/index.ts and 1 other location - About 1 hr to fix
        src/index.ts on lines 41..43

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

        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 genSSIM has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          μ12: Matrix,
          σ12: Matrix,
          μ1Sq: Matrix,
          μ2Sq: Matrix,
          σ1Sq: Matrix,
        Severity: Major
        Found in src/ssim.ts - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language