gyrodraw/GyroDraw

View on GitHub

Showing 117 of 158 total issues

Method floodFill has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    void floodFill(int x, int y) {
        prepare();

        if (startColor[0] == 0) {
            int startPixel = pixels[(width * y) + x];

    Method getGameResultsFromDb has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @Override
        public List<GameResult> getGameResultsFromDb(Context context) {
            String query = "Select * FROM " + TABLE_NAME + " ORDER BY " + COLUMN_ID + " DESC LIMIT 10";
    
            SQLiteDatabase db = this.getWritableDatabase();

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

              String createTable = "CREATE TABLE " + TABLE_NAME + "(" + COLUMN_ID
                      + " INTEGER PRIMARY KEY,"
                      + COLUMN_RANKED_USERNAME + " RANKED_USERNAME,"
                      + COLUMN_RANK + " RANK,"
                      + COLUMN_STARS + " STARS,"
      app/src/main/java/ch/epfl/sweng/GyroDraw/localDatabase/LocalDbHandlerForAccount.java on lines 45..49

      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

              String createTable = "CREATE TABLE " + TABLE_NAME + "(" + COLUMN_ID
                      + " INTEGER PRIMARY KEY," + COLUMN_USER_ID + " USER_ID," + COLUMN_USERNAME
                      + " USERNAME," + COLUMN_EMAIL + " EMAIL," + COLUMN_CURRENT_LEAGUE
                      + " CURRENT_LEAGUE," + COLUMN_TROPHIES
                      + " TROPHIES," + COLUMN_STARS + " STARS," + COLUMN_MATCHES_WON + " MATCHES_WON,"
      app/src/main/java/ch/epfl/sweng/GyroDraw/localDatabase/LocalDbHandlerForGameResults.java on lines 49..55

      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 startTimer has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function startTimer(time, roomID, prevState, newState, nodeCreation, isWaiting) {
      Severity: Minor
      Found in functions/index.js - About 45 mins to fix

        Method styleView has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            private void styleView(TextView view, String text, int color, int size, Typeface typeface,
                                   LinearLayout.LayoutParams layoutParams) {
        Severity: Minor
        Found in app/src/main/java/ch/epfl/sweng/GyroDraw/BaseActivity.java - About 45 mins to fix

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

              protected final ValueEventListener listenerTimer = new OnSuccessValueEventListener() {
                  @Override
                  public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                      Integer value = dataSnapshot.getValue(Integer.class);
          
          
          app/src/main/java/ch/epfl/sweng/GyroDraw/game/WaitingPageActivity.java on lines 80..90

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

          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

          Method bounceButton has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public static void bounceButton(final View view, double amplitude, int frequency,
                                              AnimMode animMode, Context context) {
          Severity: Minor
          Found in app/src/main/java/ch/epfl/sweng/GyroDraw/utils/LayoutUtils.java - About 35 mins to fix

            Method decodeSampledBitmapFromByteArray has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public static Bitmap decodeSampledBitmapFromByteArray(byte[] array, int offset, int length,
                                                                      int reqWidth, int reqHeight) {
            Severity: Minor
            Found in app/src/main/java/ch/epfl/sweng/GyroDraw/utils/BitmapManipulator.java - About 35 mins to fix

              Function createRoomAndJoin has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function createRoomAndJoin(league, roomsList, username, id, gameMode) {
              Severity: Minor
              Found in functions/index.js - About 35 mins to fix

                Function functionTimer has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function functionTimer (seconds, state, roomID, isWaiting, call) {
                Severity: Minor
                Found in functions/index.js - About 35 mins to fix

                  Method createTextView has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public TextView createTextView(String text, int color, int size, Typeface typeface,
                                                     LinearLayout.LayoutParams layoutParams) {
                  Severity: Minor
                  Found in app/src/main/java/ch/epfl/sweng/GyroDraw/BaseActivity.java - About 35 mins to fix

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

                        @Test
                        public void testListenerTimer() {
                            when(dataSnapshotMock.getValue(Integer.class)).thenReturn(5);
                            activityRule.getActivity().callOnDataChangeTimer(dataSnapshotMock);
                            onView(withId(R.id.timeRemaining)).check(matches(withText("5")));
                    app/src/androidTest/java/ch/epfl/sweng/GyroDraw/game/WaitingPageActivityTest.java on lines 247..253

                    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

                    Method onActivityResult has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        @Override
                        public void onActivityResult(int requestCode, int resultCode, Intent data) {
                            super.onActivityResult(requestCode, resultCode, data);
                    
                            if (requestCode == REQUEST_CODE_SIGN_IN) {
                    Severity: Minor
                    Found in app/src/main/java/ch/epfl/sweng/GyroDraw/auth/LoginActivity.java - About 35 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

                    Method generatePositionsFromRanking has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static Integer[] generatePositionsFromRanking(Integer[] ranking) {
                            Integer[] positions = new Integer[ranking.length];
                    
                            positions[0] = ranking[0] >= 0 ? FIRST_POSITION : LAST_POSITION;
                            for (int i = 1; i < positions.length; ++i) {
                    Severity: Minor
                    Found in app/src/main/java/ch/epfl/sweng/GyroDraw/utils/RankingUtils.java - About 35 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

                    Method generateTrophiesFromRanking has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static Integer[] generateTrophiesFromRanking(Integer[] ranking) {
                            Integer[] trophies = new Integer[ranking.length];
                    
                            trophies[0] = ranking[0] >= 0 ? MAX_RANK : MIN_RANK;
                            for (int i = 1; i < trophies.length; ++i) {
                    Severity: Minor
                    Found in app/src/main/java/ch/epfl/sweng/GyroDraw/utils/RankingUtils.java - About 35 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

                                promises.push(admin.database().ref(parentRoomID + roomID + "/playing").set(PlayingEnum.Idle));
                    Severity: Minor
                    Found in functions/index.js and 1 other location - About 35 mins to fix
                    functions/index.js on lines 110..110

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

                    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

                                promises.push(admin.database().ref(parentRoomID + roomID + "/state").set(StateEnum.Idle));
                    Severity: Minor
                    Found in functions/index.js and 1 other location - About 35 mins to fix
                    functions/index.js on lines 111..111

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

                    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

                    Avoid too many return statements within this function.
                    Open

                      return 0;
                    Severity: Major
                    Found in functions/index.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            return admin.database().ref(parentRoomID + roomID + "/ranking").once('value', (snapshot) => {
                              return updateDisconnectedUsers(snapshot, roomID);
                            });
                      Severity: Major
                      Found in functions/index.js - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language