yagoferrer/map-tools

View on GitHub

Showing 35 of 35 total issues

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

  constructor(public that) {

    var findMarkerInstance = new findMarker(that);

    this.findMarker = function(marker) {
Severity: Minor
Found in lib/removeMarker.ts and 1 other location - About 45 mins to fix
lib/updateMarker.ts on lines 12..19

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

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

  public static prepareOptions(options, custom) : {custom: {open?: {on: string}; close?: {on: string; duration: number}}; defaults: {}} {
    var result = {custom: {}, defaults: {}}, option;
    for (option in options) {
      if (options.hasOwnProperty(option)) {
        if (custom.indexOf(option) > -1) {
Severity: Minor
Found in lib/utils.ts - About 45 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

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

  constructor(public that) {

    var findMarkerInstance = new findMarker(that);

    this.findMarker = function(marker) {
Severity: Minor
Found in lib/updateMarker.ts and 1 other location - About 45 mins to fix
lib/removeMarker.ts on lines 10..17

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

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

Avoid deeply nested control flow statements.
Open

            if (!this.that.json.filter) {
              this.addFilter(options.filters);
            }
Severity: Major
Found in lib/addFeature.ts - About 45 mins to fix

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

      removeTags(marker) {
        if (utils.isArray(marker.tags)) {
          var i, tag;
          for (i in marker.tags) {
            if (marker.tags.hasOwnProperty(i)) {
    Severity: Minor
    Found in lib/updateMarker.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

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

      public update(args, options){
        var type = Object.prototype.toString.call(args);
    
        if (type === '[object Array]') {
          var feature, x;
    Severity: Minor
    Found in lib/updateFeature.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

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

      private formatOptions(marker, options) {
        var key, op = {};
        var type = Object.prototype.toString.call(options);
    
        if (type === '[object String]') {
    Severity: Minor
    Found in lib/resetMarker.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

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

      clearAll(dimensionSet){
        var i, dimension;
        for (i in dimensionSet){
    
          if (dimensionSet.hasOwnProperty(i)) {
    Severity: Minor
    Found in lib/filter.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

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

      public update(args, options) {
    
        var visibilityFlag = false;
        var preparedOptions = utils.prepareOptions(options, config.customMarkerOptions);
        if (preparedOptions.defaults && preparedOptions.defaults.hasOwnProperty('visible') && this.that.events.indexOf('marker_visibility_changed') > -1) {
    Severity: Minor
    Found in lib/updateMarker.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

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

      public load(type, url, cb) {
    
      if (this.that.templates[type][url]) {
        return this.that.templates[type][url];
      }
    Severity: Minor
    Found in lib/template.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

    Function getCommonObject has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      public static getCommonObject(list1, list2){
        var result = {};
        for (var uid in list1) {
          if (list1.hasOwnProperty(uid)) {
            var match = list2[uid];
    Severity: Minor
    Found in lib/utils.ts - 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

    Function addTags has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      addTags(marker, options) {
    
        if (utils.isArray(options.custom.tags)) {
          var i, tag;
          for (i in options.custom.tags) {
    Severity: Minor
    Found in lib/updateMarker.ts - 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

    Function load has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      public load(options: mapToolsOptions, cb: mapToolsCallback) {
    
        if (this.validOptions(options, cb)) {
    
          var id = options.id || options.el.substring(1);
    Severity: Minor
    Found in lib/addMap.ts - 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

    Function addPanel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      public addPanel(options, cb) {
    
        cb = cb || function () {};
    
        var position,
    Severity: Minor
    Found in lib/addPanel.ts - 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

    Function addExtraOptions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      addExtraOptions(marker, options) {
        var i;
        for (i in options) {
          if (options.hasOwnProperty(i)) {
            if (!options.filters) { // Filters is a special property that we don't need to add to the Marker.
    Severity: Minor
    Found in lib/addMarker.ts - 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