wouterbulten/slacjs

View on GitHub

Showing 44 of 44 total issues

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

    bestParticle() {
        let best = this.particles[0];

        this.particles.forEach((p) => {
            if (p.weight > best.weight) {
Severity: Major
Found in src/app/models/landmark-particle-set.js and 1 other location - About 2 hrs to fix
src/app/models/particle-set.js on lines 112..122

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

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

    bestParticle() {
        let best = this.particleList[0];

        this.particleList.forEach((p) => {
            if (p.weight > best.weight) {
Severity: Major
Found in src/app/models/particle-set.js and 1 other location - About 2 hrs to fix
src/app/models/landmark-particle-set.js on lines 94..104

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

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 (this.accelerometerId === undefined) {
            this.accelerometerId = navigator.accelerometer.watchAcceleration(
                (data) => this._updateAccelerometer(data),
                (error) => this._onError(error),
                this.listenerOptions
Severity: Major
Found in src/app/device/motion-sensor.js and 1 other location - About 1 hr to fix
src/app/device/motion-sensor.js on lines 45..51

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

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 (this.compassId === undefined) {
            this.compassId = navigator.compass.watchHeading(
                (data) => this._updateCompass(data),
                (error)    =>this._onError(error),
                this.compassOptions
Severity: Major
Found in src/app/device/motion-sensor.js and 1 other location - About 1 hr to fix
src/app/device/motion-sensor.js on lines 37..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 68.

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

    start() {

        console.log('[SLACjs] Starting');

        this.uiElements.btnStart.prop('disabled', true);
Severity: Minor
Found in src/app/app-mobile.js - About 1 hr to fix

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

        plot: function() {
            $('#test-content').highcharts({
                chart: {
                    type: 'scatter'
                },    
    Severity: Minor
    Found in src/tests/rssi-filter.js - About 1 hr to fix

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

                  const dist = Math.sqrt(Math.pow(trueL.x - l.x, 2) + Math.pow(trueL.y - l.y, 2));
      Severity: Major
      Found in src/app/app-replay.js and 1 other location - About 1 hr to fix
      src/app/app-local.js on lines 114..114

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

      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

                  const dist = Math.sqrt(Math.pow(trueL.x - l.x, 2) + Math.pow(trueL.y - l.y, 2));
      Severity: Major
      Found in src/app/app-local.js and 1 other location - About 1 hr to fix
      src/app/app-replay.js on lines 217..217

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

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

          start() {
      
              //Store the current heading
              this.startHeading = SlacJsData.motion[0].heading;
      
      
      Severity: Minor
      Found in src/app/app-replay.js - About 1 hr to fix

        Function _initErrorPlot has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            _initErrorPlot() {
        
                this.errorPlot = {
        
                    data: [],
        Severity: Minor
        Found in src/app/app-replay.js - About 1 hr to fix

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

              updateScaleFactor(user, landmarks) {
          
                  let maxX = 0;
                  let maxY = 0;
          
          
          Severity: Minor
          Found in src/app/view/particle-renderer.js - About 1 hr to fix

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

                save(data) {
            
                    data = 'SlacJsData =  ' + JSON.stringify(data) + ';';
            
                    /*
            Severity: Minor
            Found in src/app/device/data-storage.js - About 1 hr to fix

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

                  _addLandmark(uid, name) {
              
                      const uiId = 'activity-' + uid;
                      const friendlyName = this._friendlyName(name);
              
              
              Severity: Minor
              Found in src/app/view/landmark-activity-panel.js - About 1 hr to fix

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

                    _midpointCircle(row, column, r) {
                
                        let x = r;
                        let y = 0;
                        let radiusError = 1 - x;
                Severity: Minor
                Found in src/app/models/vote-accumulator.js - About 1 hr to fix

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

                      _draw: function() {
                  
                          this.ctx.clearRect (0, 0, this.canvas.width, this.canvas.height);
                          this.ctx.fillStyle = '#000000';
                  
                  
                  Severity: Minor
                  Found in src/tests/landmark-init.js - About 1 hr to fix

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

                            particleSet.particles().forEach((p) => {
                    
                                if (p === best) {
                                    return;
                                }
                    Severity: Major
                    Found in src/app/view/particle-renderer.js and 1 other location - About 1 hr to fix
                    src/app/view/replay-renderer.js on lines 35..42

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

                    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

                            const r = Math.sqrt(Math.pow(this.lX - this.userX, 2) + Math.pow(this.lY - this.userY, 2));
                    Severity: Major
                    Found in src/tests/landmark-init.js and 1 other location - About 1 hr to fix
                    src/tests/voting.js on lines 39..39

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

                    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

                            const r = Math.sqrt(Math.pow(this.lX - this.userX, 2) + Math.pow(this.lY - this.userY, 2)) + (Math.random() * 6 - 3);
                    Severity: Major
                    Found in src/tests/voting.js and 1 other location - About 1 hr to fix
                    src/tests/landmark-init.js on lines 82..82

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

                    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

                            particleSet.particles().forEach((p) => {
                    
                                if (p === best) {
                                    return;
                                }
                    Severity: Major
                    Found in src/app/view/replay-renderer.js and 1 other location - About 1 hr to fix
                    src/app/view/particle-renderer.js on lines 37..44

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

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

                        processObservation(obs) {
                    
                            if (obs !== {}) {
                    
                                const { uid, r, name, moved } = obs;
                    Severity: Minor
                    Found in src/app/models/particle-set.js - About 55 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