Showing 225 of 225 total issues
File plan-trip.component.ts
has 337 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { Component, ViewChild, ElementRef } from '@angular/core';
import { Geolocation } from '@ionic-native/geolocation';
import { NavController, LoadingController, AlertController, NavParams } from 'ionic-angular';
import { StopService } from '../../providers/stop.service';
import { MapService } from '../../providers/map.service';
Function getRoute
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
getRoute(): void {
if (this.originDestToast) {
this.toastSvc.noOriginOrDestinationToast();
}
// We need an origin and destination
File routes-and-stops.component.ts
has 273 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { Component } from '@angular/core';
import { NavController, LoadingController, AlertController } from 'ionic-angular';
import { Storage } from '@ionic/storage';
import { Geolocation } from '@ionic-native/geolocation';
import { RouteService } from '../../providers/route.service';
Function constructMap
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructMap(): void {
var mapOptions = {
zoom: 15,
mapTypeControl: false,
mapTypeId: google.maps.MapTypeId.ROADMAP,
File stop.component.ts
has 262 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { Component, ChangeDetectorRef } from '@angular/core';
import { NavController, NavParams, LoadingController, AlertController } from 'ionic-angular';
import { Storage } from '@ionic/storage';
import { StopDeparture } from '../../models/stop-departure.model';
Function toggleOrdering
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
toggleOrdering(): void {
this.onSearchQueryChanged(this.searchQuery);
var routeOrderings = ['favorites', 'name'];
var stopOrderings = ['favorites', 'distance'];
let primarySort: string;
Function sort
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
sort (directions): any {
this.departuresByTime = [];
this.departuresByDirection = [];
// Avail returns an array of RouteDirections. We must deal
// with the Departures for each Direction.
- Read upRead up
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 getRoute
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
getRoute(): void {
if (this.originDestToast) {
this.toastSvc.noOriginOrDestinationToast();
}
// We need an origin and destination
- Read upRead up
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 toggleOrdering
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
toggleOrdering(): void {
this.onSearchQueryChanged(this.searchQuery);
var routeOrderings = ['favorites', 'name'];
var stopOrderings = ['favorites', 'distance'];
let primarySort: string;
- Read upRead up
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 ionViewWillEnter
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
ionViewWillEnter() {
this.getAlerts();
this.favoriteStopSvc.contains(this.stopId, (liked) => {
this.liked = liked;
});
Function loadLocation
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
loadLocation(): void {
let options = {timeout: 5000, enableHighAccuracy: true};
this.geolocation.getCurrentPosition(options).then(position => {
// Geocode current position to retrieve its corresponding Google Maps ID
new google.maps.Geocoder().geocode(
Function placeVehicles
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
placeVehicles (isVehicleRefresh) {
// Places every vehicle on said route on the map
this.mapSvc.removeAllMarkers();
if (!this.vehicles) {
return;
Function reload
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
reload(loadedTrip): void {
// @TODO Scroll to input area first
this.constructMap();
this.noLocation = false;
// If we loaded a trip (user came via
Function sort
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
sort (directions): any {
this.departuresByTime = [];
this.departuresByDirection = [];
// Avail returns an array of RouteDirections. We must deal
// with the Departures for each Direction.
Function saveTrip
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
saveTrip(): void {
console.log('saving trip yo');
this.alertCtrl.create({
title: 'Save Trip',
message: 'Give this trip a name',
Function getDepartures
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
getDepartures(refresher?: any): void {
this.stopDepartureSvc.getStopDeparture(this.stopId)
.then(directions => {
this.sort(directions[0]);
let routeIds = _.uniq(_.map(directions[0].RouteDirections, 'RouteId'));
Function getRouteList
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
getRouteList(): Promise<any> {
console.log('getroutelist top');
return this.storage.ready().then(() => {
console.log('getroutelist storage ready');
return this.storage.get('routes').then((routes) => {
Function calculateStopDistances
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
calculateStopDistances(position?): void {
if (position) {
var currentPosition = {
latitude: position.coords.latitude,
longitude: position.coords.longitude
Function reload
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
reload(loadedTrip): void {
// @TODO Scroll to input area first
this.constructMap();
this.noLocation = false;
// If we loaded a trip (user came via
- Read upRead up
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
Avoid deeply nested control flow statements. Open
if (!_.includes(this.alerts, alert)) {
this.alerts.push(alert);
}