donmahallem/TrapezeClientNg

View on GitHub

Showing 40 of 40 total issues

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

                    const marker: L.Marker = L.marker([location.latitude / 3600000, location.longitude / 3600000],
                        {
                            icon: vehicleIcon,
                            interactive: false,
                            title: location.name,
Severity: Major
Found in src/app/modules/trip-passages/follow-bus-map.directive.ts and 1 other location - About 1 hr to fix
src/app/modules/stop/stop-map.directive.ts on lines 67..73

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

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

                    const marker: L.Marker = L.marker([location.latitude / 3600000, location.longitude / 3600000],
                        {
                            icon: stopIcon,
                            interactive: false,
                            title: location.name,
Severity: Major
Found in src/app/modules/stop/stop-map.directive.ts and 1 other location - About 1 hr to fix
src/app/modules/trip-passages/follow-bus-map.directive.ts on lines 66..72

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

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 (this.stopMarkerLayer) {
                    this.stopMarkerLayer.clearLayers();
                } else {
                    this.stopMarkerLayer = new L.FeatureGroup();
                    this.stopMarkerLayer.addTo(this.getMap());
Severity: Major
Found in src/app/modules/trip-passages/follow-bus-map.directive.ts and 1 other location - About 1 hr to fix
src/app/modules/stop/stop-map.directive.ts on lines 59..64

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

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 (this.stopMarkerLayer) {
                    this.stopMarkerLayer.clearLayers();
                } else {
                    this.stopMarkerLayer = new L.FeatureGroup();
                    this.stopMarkerLayer.addTo(this.getMap());
Severity: Major
Found in src/app/modules/stop/stop-map.directive.ts and 1 other location - About 1 hr to fix
src/app/modules/trip-passages/follow-bus-map.directive.ts on lines 57..62

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

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

    public ngAfterViewInit() {
        super.ngAfterViewInit();
        this.addMarker();
        this.startVehicleUpdater();
        const ourCustomControl = L.Control.extend({
Severity: Minor
Found in src/app/modules/main-map/main-map.directive.ts - About 1 hr to fix

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

        public getRouteByVehicleId(vehicleId: VehicleId): Observable<IVehiclePathInfo> {
            return this.http.get<IVehiclePathInfo>(this.baseUrl() + 'api/vehicle/' + vehicleId + '/route');
        }
    Severity: Major
    Found in src/app/services/api.service.ts and 4 other locations - About 1 hr to fix
    src/app/services/api.service.ts on lines 30..32
    src/app/services/api.service.ts on lines 36..38
    src/app/services/api.service.ts on lines 39..41
    src/app/services/api.service.ts on lines 42..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 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 5 locations. Consider refactoring.
    Open

        public getRouteByTripId(tripId: TripId): Observable<IVehiclePathInfo> {
            return this.http.get<IVehiclePathInfo>(this.baseUrl() + 'api/trip/' + tripId + '/route');
        }
    Severity: Major
    Found in src/app/services/api.service.ts and 4 other locations - About 1 hr to fix
    src/app/services/api.service.ts on lines 30..32
    src/app/services/api.service.ts on lines 33..35
    src/app/services/api.service.ts on lines 39..41
    src/app/services/api.service.ts on lines 42..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 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 5 locations. Consider refactoring.
    Open

        public getStopInfo(stopId: StopId): Observable<IStopInfo> {
            return this.http.get<IStopInfo>(this.baseUrl() + 'api/stop/' + stopId + '/info');
        }
    Severity: Major
    Found in src/app/services/api.service.ts and 4 other locations - About 1 hr to fix
    src/app/services/api.service.ts on lines 30..32
    src/app/services/api.service.ts on lines 33..35
    src/app/services/api.service.ts on lines 36..38
    src/app/services/api.service.ts on lines 42..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 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 5 locations. Consider refactoring.
    Open

        public getTripPassages(tripId: TripId): Observable<TripPassagesLocation> {
            return this.http.get<TripPassagesLocation>(this.baseUrl() + 'api/trip/' + tripId + '/passages?mode=departure');
        }
    Severity: Major
    Found in src/app/services/api.service.ts and 4 other locations - About 1 hr to fix
    src/app/services/api.service.ts on lines 33..35
    src/app/services/api.service.ts on lines 36..38
    src/app/services/api.service.ts on lines 39..41
    src/app/services/api.service.ts on lines 42..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 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 5 locations. Consider refactoring.
    Open

        public getStopPassages(stopId: StopId): Observable<IStopPassage> {
            return this.http.get<IStopPassage>(this.baseUrl() + 'api/stop/' + stopId + '/departures');
        }
    Severity: Major
    Found in src/app/services/api.service.ts and 4 other locations - About 1 hr to fix
    src/app/services/api.service.ts on lines 30..32
    src/app/services/api.service.ts on lines 33..35
    src/app/services/api.service.ts on lines 36..38
    src/app/services/api.service.ts on lines 39..41

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

        public addMarker(): void {
            this.updateObservable = this.vehicleLocationSubject
                .pipe(map((loc: ITimestampVehicleLocation) => loc.vehicle))
                .subscribe((location) => {
                    if (this.stopMarkerLayer) {
    Severity: Minor
    Found in src/app/modules/trip-passages/follow-bus-map.directive.ts - About 1 hr to fix

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

              this.sidenav.openedChange.subscribe((open) => {
                  if (open) {
                      this.sidebarService.openSidebar();
                  } else {
                      this.sidebarService.closeSidebar();
      Severity: Major
      Found in src/app/app.component.ts and 1 other location - About 1 hr to fix
      src/app/app.component.ts on lines 28..35

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

      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.sidebarService.sidebarObservable
                  .subscribe((open) => {
                      if (open) {
                          this.sidenav.open();
                      } else {
      Severity: Major
      Found in src/app/app.component.ts and 1 other location - About 1 hr to fix
      src/app/app.component.ts on lines 36..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 64.

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

          public setVehicles(vehicles: IVehicleLocationList): void {
              if (this.vehicleMarkerLayer !== undefined) {
                  this.vehicleMarkerLayer.clearLayers();
              } else {
                  this.vehicleMarkerLayer = L.featureGroup();
      Severity: Minor
      Found in src/app/modules/main-map/main-map.directive.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 start has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public start(): void {
              if (this.subscription && !this.subscription.closed) {
                  return;
              }
              this.subscription = this.updateSubject
      Severity: Minor
      Found in src/app/modules/main-map/main-map-route-display-handler.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 ngAfterViewInit has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public ngAfterViewInit(): void {
              this.mTimerObservable = timer(this.tickInterval, this.tickInterval);
              this.mTimerObservable.subscribe((tick: number) => {
                  const ticksLeft: number = this.ticksToRefresh - (tick % this.ticksToRefresh);
                  const diff: number = Math.round((ticksLeft * this.tickInterval) / 1000);
      Severity: Minor
      Found in src/app/modules/stop/stop-info.component.ts - About 1 hr to fix

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

                    onAdd: () => {
                        const container = L.DomUtil.create('i', 'material-icons leaflet-bar leaflet-control leaflet-control-custom');
                        container.style.backgroundColor = 'white';
                        container.style.width = '42px';
                        container.style.height = '42px';
        Severity: Minor
        Found in src/app/modules/main-map/main-map.directive.ts - About 1 hr to fix

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

              public startUpdater(): void {
                  if (this.updateSubscription) {
                      return;
                  }
                  this.updateSubscription = this.stopLocationSubject
          Severity: Minor
          Found in src/app/modules/stop/stop-map.directive.ts - About 1 hr to fix

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

                                this.getMap().panTo({
                                    alt: 2000,
                                    lat: location.latitude / 3600000,
                                    lng: location.longitude / 3600000,
                                },
            Severity: Major
            Found in src/app/modules/trip-passages/follow-bus-map.directive.ts and 1 other location - About 1 hr to fix
            src/app/modules/stop/stop-map.directive.ts on lines 75..80

            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

                                this.getMap().panTo({
                                    alt: 2000,
                                    lat: location.latitude / 3600000,
                                    lng: location.longitude / 3600000,
                                },
            Severity: Major
            Found in src/app/modules/stop/stop-map.directive.ts and 1 other location - About 1 hr to fix
            src/app/modules/trip-passages/follow-bus-map.directive.ts on lines 75..80

            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

            Severity
            Category
            Status
            Source
            Language