hyperrail/hyperrail-for-android

View on GitHub

Showing 392 of 393 total issues

Method parseRoute has a Cognitive Complexity of 28 (exceeds 15 allowed). Consider refactoring.
Open

    private Route parseRoute(JSONObject routeObject) throws JSONException, StopLocationNotResolvedException {
        JSONObject departure = routeObject.getJSONObject("departure");
        JSONObject arrival = routeObject.getJSONObject("arrival");

        TransportOccupancyLevel departureOccupancyLevel = parseOccupancyLevel(departure);

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

Method generateStopArray has a Cognitive Complexity of 28 (exceeds 15 allowed). Consider refactoring.
Open

    @AddTrace(name = "LiveboardResponseListener.createStopArray")
    private VehicleStopImpl[] generateStopArray() {
        // Find stops (train arrives and leaves again)
        ArrayList<LinkedConnection> handledConnections = new ArrayList<>();

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

File NmbsToMlgDessinsAdapter.java has 254 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 *  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
 *  If a copy of the MPL was not distributed with this file,
 *  You can obtain one at http://mozilla.org/MPL/2.0/.
 */

    Method showError has a Cognitive Complexity of 25 (exceeds 15 allowed). Consider refactoring.
    Open

        protected final void showError(Exception exception) {
            if (exception instanceof ServerError) {
                if (((ServerError) exception).networkResponse != null) {
                    if (((ServerError) exception).networkResponse.statusCode == 404) {
                        showError(R.string.error_no_results_found);

    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

    Method loadFacilitiesCursor has 69 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

        private StopLocationFacilitiesImpl loadFacilitiesCursor(Cursor c) {
            if (c.isClosed()) {
                log.severe("Tried to load closed cursor");
                return null;
            }

      Method loadStationCursor has 66 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

          @NonNull
          private StopLocation[] loadStationCursor(@NonNull Cursor c) {
              if (c.isClosed()) {
                  log.severe("Tried to load closed cursor");
                  return new StopLocation[0];

        Method drawTrainJourneyOnMap has 62 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

            private void drawTrainJourneyOnMap(GoogleMap map) {
                final LatLng locations[] = new LatLng[mCurrentTrain.getStops().length];
                final List<LatLng> passedLocations = new ArrayList<>();
                final List<LatLng> futureLocations = new ArrayList<>();
                LatLngBounds.Builder builder = new LatLngBounds.Builder();

          Method bindNotificationButton has 60 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

              private void bindNotificationButton(final Dialog vDialog, LinearLayout vSetNotification) {
                  vSetNotification.setOnClickListener(new OnClickListener() {
                      @Override
                      public void onClick(View v) {
                          NotificationManager mNotifyMgr =

            Method getFilter has a Cognitive Complexity of 21 (exceeds 15 allowed). Consider refactoring.
            Open

                @Override
                public Filter getFilter() {
                    return new Filter() {
                        class MultilangFilterResults extends FilterResults {
                            public MultilangFilterResults(List<StopLocation> results) {

            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

            Method onSuccessResponse has 55 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

                @Override
                @AddTrace(name = "LiveboardResponseListener.onSuccess")
                public void onSuccessResponse(@NonNull LinkedConnections data, Object tag) {
            
                    ((MeteredRequest) tag).setMsecUsableNetworkResponse(DateTime.now().getMillis());

              Method extend has 54 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

                  private void extend(LinkedConnectionsRoutesList routes) {
                      attempts++;
              
                      if (attempts > 12) {
                          mRequest.notifyErrorListeners(new FileNotFoundException());

                Method getStationFacilitiesByUri has 54 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                    @Override
                    public StopLocationFacilities getStationFacilitiesByUri(String uri) {
                        SQLiteDatabase db = mWebDb.getReadableDatabase();
                        Cursor c = db.query(
                                StationFacilityColumns.TABLE_NAME,

                  Method getLinkedConnectionsByUrl has 53 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                      void getLinkedConnectionsByUrl(final String url, final TransportDataSuccessResponseListener<LinkedConnections> successListener, final TransportDataErrorResponseListener errorListener, final Object tag) {
                          // https://graph.irail.be/sncb/connections?departureTime={ISO8601}
                          if (BuildConfig.DEBUG) {
                              Log.i("LCProvider", "Loading " + url);
                          }

                    Method getLinkedConnectionsByUrl has a Cognitive Complexity of 20 (exceeds 15 allowed). Consider refactoring.
                    Open

                        void getLinkedConnectionsByUrl(final String url, final TransportDataSuccessResponseListener<LinkedConnections> successListener, final TransportDataErrorResponseListener errorListener, final Object tag) {
                            // https://graph.irail.be/sncb/connections?departureTime={ISO8601}
                            if (BuildConfig.DEBUG) {
                                Log.i("LCProvider", "Loading " + url);
                            }

                    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

                    Method onSuccessResponse has a Cognitive Complexity of 20 (exceeds 15 allowed). Consider refactoring.
                    Open

                        @Override
                        @AddTrace(name = "LiveboardResponseListener.onSuccess")
                        public void onSuccessResponse(@NonNull LinkedConnections data, Object tag) {
                    
                            ((MeteredRequest) tag).setMsecUsableNetworkResponse(DateTime.now().getMillis());

                    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

                    Method onSuccessResponse has 52 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                        @Override
                        @AddTrace(name = "VehicleResponseListener.sucess")
                        public void onSuccessResponse(@NonNull LinkedConnections data, Object tag) {
                            ((MeteredDataSource.MeteredRequest) tag).setMsecUsableNetworkResponse(DateTime.now().getMillis());
                            List<VehicleStopImpl> stops = new ArrayList<>();

                      Method extend has a Cognitive Complexity of 19 (exceeds 15 allowed). Consider refactoring.
                      Open

                          private void extend(LinkedConnectionsRoutesList routes) {
                              attempts++;
                      
                              if (attempts > 12) {
                                  mRequest.notifyErrorListeners(new FileNotFoundException());

                      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

                      Method store has a Cognitive Complexity of 18 (exceeds 15 allowed). Consider refactoring.
                      Open

                          public <T extends TransportDataRequest> void store(Suggestion<T> query) {
                              if (query.getData().getClass() == RoutePlanningRequest.class) {
                                  if (query.getType() == FAVORITE) {
                                      store(TAG_FAV_ROUTES, (RoutePlanningRequest) query.getData(),
                                              RoutePlanningRequest.class);

                      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

                      Method buildDepartureVehicleStop has 10 arguments (exceeds 8 allowed). Consider refactoring.
                      Open

                          public static VehicleStopImpl buildDepartureVehicleStop(StopLocation station, VehicleJourneyStub train, String platform, boolean isPlatformNormal, DateTime departureTime, Duration departureDelay, boolean departureCanceled, boolean hasLeft, String semanticDepartureConnection, TransportOccupancyLevel occupancyLevel) {

                        Method buildArrivalVehicleStop has 10 arguments (exceeds 8 allowed). Consider refactoring.
                        Open

                            public static VehicleStopImpl buildArrivalVehicleStop(StopLocation station, VehicleJourneyStub train, String platform, boolean isPlatformNormal, DateTime arrivalTime, Duration arrivalDelay, boolean arrivalCanceled, boolean hasArrived, String semanticDepartureConnection, TransportOccupancyLevel occupancyLevel) {
                          Severity
                          Category
                          Status
                          Source
                          Language