rexxars/vinmonopolet

View on GitHub

Showing 11 of 11 total issues

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

  Object.keys(product).forEach(key => {
    const [name, valueFilter] = productMap[key] || []
    const fieldName = name || camelcase(key)
    this[fieldName] = valueFilter ? valueFilter(product[key]) : product[key]
  })
Severity: Major
Found in src/models/Product.js and 1 other location - About 2 hrs to fix
src/models/Store.js on lines 5..9

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

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

  Object.keys(store).forEach(key => {
    const [name, valueFilter] = storeStreamMap[key] || []
    const fieldName = name || camelcase(key)
    this[fieldName] = valueFilter ? valueFilter(store[key]) : store[key]
  })
Severity: Major
Found in src/models/Store.js and 1 other location - About 2 hrs to fix
src/models/Product.js on lines 82..86

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

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

function Product(product) {
  // Core product info
  this.code = product.code
  this.name = product.name
  this.productType = (product.main_category && product.main_category.name) || null
Severity: Major
Found in src/models/Product.js - About 2 hrs to fix

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

    function getProduct(code) {
      const query = {fields: 'FULL'}
      return request.get(`/products/${code}`, {query})
        .then(product => new Product(product))
    }
    Severity: Major
    Found in src/retrievers/getProduct.js and 1 other location - About 1 hr to fix
    src/retrievers/getProductByBarcode.js on lines 4..8

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

    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 getProductByBarcode(barcode) {
      const query = {fields: 'FULL'}
      return request.get(`/products/barCodeSearch/${barcode}`, {query})
        .then(product => new Product(product))
    }
    Severity: Major
    Found in src/retrievers/getProductByBarcode.js and 1 other location - About 1 hr to fix
    src/retrievers/getProduct.js on lines 4..8

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

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

    function getProducts(opts) {
      const options = objectAssign({}, defaults, opts || {})
      const query = {
        pageSize: options.limit,
        currentPage: Math.max(0, options.page - 1),
    Severity: Minor
    Found in src/retrievers/getProducts.js - About 1 hr to fix

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

      function FoodPairing(ref) {
        this.code = ref.code
        this.identifier = ref.identifier
        this.name = ref.name
      }
      Severity: Minor
      Found in src/models/FoodPairing.js and 1 other location - About 40 mins to fix
      src/models/Category.js on lines 1..5

      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

      module.exports = function Category(cat) {
        this.code = cat.code
        this.name = cat.name
        this.url = cat.url
      }
      Severity: Minor
      Found in src/models/Category.js and 1 other location - About 40 mins to fix
      src/models/FoodPairing.js on lines 1..5

      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

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

      function symmetricLine(chunk, enc, callback) {
        let numQuotes = 0
        let lastPos
      
        // Look for quote (") character
      Severity: Minor
      Found in src/util/symmetric-stream.js - 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 getProducts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      function getProducts(opts) {
        const options = objectAssign({}, defaults, opts || {})
        const query = {
          pageSize: options.limit,
          currentPage: Math.max(0, options.page - 1),
      Severity: Minor
      Found in src/retrievers/getProducts.js - 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 getSortParam has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function getSortParam(sort) {
        if (!sort) {
          return undefined
        }
      
      
      Severity: Minor
      Found in src/retrievers/getProducts.js - 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

      Severity
      Category
      Status
      Source
      Language