alientronics/fleetany-mobile

View on GitHub

Showing 43 of 43 total issues

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

  it('should get Bluetooth data', () => {
    spyOn(instance, 'getBluetoothCurrentData').and.returnValue(new PromiseMock('[{\"blescan\":1,\"bledevice\":0,\"devices\":0,\"datastream\":0}]'));
    instance.setDisplayData();
    expect(instance.getBluetoothCurrentData).toHaveBeenCalled();
  });
Severity: Major
Found in src/providers/bluetooth.spec.ts and 1 other location - About 1 hr to fix
src/providers/gps.spec.ts on lines 70..74

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

  it('should set Display data', () => {
    spyOn(instance, 'getGpsCurrentData').and.returnValue(new PromiseMock('[{\"latitude\":1,\"longitude\":0,\"gpstracking\":0}]'));
    instance.setDisplayData();
    expect(instance.getGpsCurrentData).toHaveBeenCalled();
  });
Severity: Major
Found in src/providers/gps.spec.ts and 1 other location - About 1 hr to fix
src/providers/bluetooth.spec.ts on lines 161..165

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

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', 'angular-cli'],
    plugins: [
Severity: Minor
Found in karma.conf.js - About 1 hr to fix

    Function processTireData has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      processTireData(buffer: ArrayBuffer):any {
    
        var dataView = new DataView(buffer);
    
        if (dataView.getUint8(0) != 0xAA 
    Severity: Minor
    Found in src/providers/service.ts - About 1 hr to fix

      Function _printDataView has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _printDataView(dataView: DataView) {
          //alert("tire data: " + this.uart._buffer2String(dataView.buffer));
      
          if (dataView.byteLength > 4 && dataView.getUint8(3) == dataView.byteLength) {
            var tire = this.uart.processTireData(dataView.buffer);
      Severity: Minor
      Found in src/providers/bluetooth.ts - About 1 hr to fix

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

                  for (let i = 0; i < this.positions; i++) { 
                    setTimeout(function(){ thing.askTiresData(i+1); }, i*500);
                  }
        Severity: Major
        Found in src/providers/bluetooth.ts and 1 other location - About 1 hr to fix
        src/providers/bluetooth.ts on lines 104..106

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

        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

            this.userData.getPlate().then((plate) => {
              this._zone.run(() => {
                this.plate = plate;
              });
            });
        Severity: Major
        Found in src/pages/login/login.ts and 1 other location - About 1 hr to fix
        src/pages/login/login.ts on lines 147..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 59.

        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

            this.userData.getVehicles().then((vehicles) => {
              this._zone.run(() => {
                this.vehicles = vehicles;
              });
            });
        Severity: Major
        Found in src/pages/login/login.ts and 1 other location - About 1 hr to fix
        src/pages/login/login.ts on lines 153..157

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

        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

                    for (let i = 0; i < this.positions; i++) { 
                      setTimeout(function(){ thing.inflatePair1(i+1); }, i*500);
                    }
        Severity: Major
        Found in src/providers/bluetooth.ts and 1 other location - About 1 hr to fix
        src/providers/bluetooth.ts on lines 93..95

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

        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

            instance = new FleetanyApp(
                        <any>new Platform(),
                        <any>new Events(), 
                        <any>new UserDataMock(),
                        <any>new AlertsProviderMock(),
        Severity: Major
        Found in src/app/app.spec.ts and 1 other location - About 1 hr to fix
        src/providers/bluetooth.spec.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 58.

        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

            instance = new BluetoothProvider(
                        <any>new Events(), 
                        <any>new Platform(),
                        <any>new UserDataMock(),
                        <any>new GpsProviderMock(),
        Severity: Major
        Found in src/providers/bluetooth.spec.ts and 1 other location - About 1 hr to fix
        src/app/app.spec.ts on lines 20..27

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

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

          subscribeRepeater() {
            var thing = this;
            BluetoothSerial.isConnected().then(
              (result) => {
                this.watcher = BluetoothSerial.subscribeRawData().subscribe(
        Severity: Minor
        Found in src/providers/bluetooth.ts - About 1 hr to fix

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

            public get(key: string): Promise<{}> {
              return new Promise((resolve: Function) => {
                resolve({key: key});
              });
            }
          Severity: Major
          Found in src/mocks.ts and 1 other location - About 1 hr to fix
          src/mocks.ts on lines 84..88

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

          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

            public remove(key: string): Promise<{}> {
              return new Promise((resolve: Function) => {
                resolve({key: key});
              });
            }
          Severity: Major
          Found in src/mocks.ts and 1 other location - About 1 hr to fix
          src/mocks.ts on lines 72..76

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

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

            onSubmit(value: any): void { 
                if(this.fuelForm.valid || value.valid) {
                    console.log('Submitted value: ', value);
          
                    let params: any = {};
          Severity: Minor
          Found in src/pages/fuel/fuel.ts - About 1 hr to fix

            Function _resetIfHasStart has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              _resetIfHasStart(cbPrint: (dataView: DataView) => void) {
                var dataView = new DataView(this.buffer);
            
                for (let i = 1; i < dataView.byteLength; i++) { 
                  if (dataView.getUint8(i) == 0xAA && dataView.byteLength > (i + 2)) {
            Severity: Minor
            Found in src/providers/service.ts - 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

            Function processTireData has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              processTireData(buffer: ArrayBuffer):any {
            
                var dataView = new DataView(buffer);
            
                if (dataView.getUint8(0) != 0xAA 
            Severity: Minor
            Found in src/providers/service.ts - 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

            Function gpsToggle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              gpsToggle(value) {
                if (this.userData.plate == null) {
                  this.userData.showToast('Vehicle should be selected!', 'Error!', this.alertCtrl);
                } else {
                  if (value) {
            Severity: Minor
            Found in src/providers/gps.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

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

            export class GpsProviderMock {
            
              public getGpsCurrentData(): any {
                return new Promise((resolve: Function) => {
                  resolve('[{\"latitude\":1,\"longitude\":0,\"gpstracking\":1,\"count\":0}]');
            Severity: Minor
            Found in src/mocks.ts and 1 other location - About 35 mins to fix
            src/mocks.ts on lines 91..99

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

            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

            export class GeofenceProviderMock {
            
              public getGeofenceData(): any {
                return new Promise((resolve: Function) => {
                  resolve('[1, 5]');
            Severity: Minor
            Found in src/mocks.ts and 1 other location - About 35 mins to fix
            src/mocks.ts on lines 60..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 47.

            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

            Severity
            Category
            Status
            Source
            Language