gyrodraw/GyroDraw

View on GitHub

Showing 117 of 158 total issues

File index.js has 374 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// The Cloud Functions for Firebase SDK to create Cloud Functions and setup triggers.
const functions = require('firebase-functions');

// The Firebase Admin SDK to access the Firebase Realtime Database.
const admin = require('firebase-admin');
Severity: Minor
Found in functions/index.js - About 5 hrs to fix

    Method onCreate has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_home);
            profileWindow = new Dialog(this);
    Severity: Major
    Found in app/src/main/java/ch/epfl/sweng/GyroDraw/home/HomeActivity.java - About 2 hrs to fix

      Method onCreate has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_voting_page);
              overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
      Severity: Major
      Found in app/src/main/java/ch/epfl/sweng/GyroDraw/game/VotingPageActivity.java - About 2 hrs to fix

        Method retrieveDrawingsFromDatabaseStorage has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private void retrieveDrawingsFromDatabaseStorage() {
                FbDatabase.getRoomAttribute(roomId, USERS,
                        new OnSuccessValueEventListener() {
                            @Override
                            public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
        Severity: Major
        Found in app/src/main/java/ch/epfl/sweng/GyroDraw/game/VotingPageActivity.java - About 2 hrs to fix

          Method setListener has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private void setListener(final View view, final double amplitude, final int frequency) {
                  final Context context = this;
                  view.setOnTouchListener(new View.OnTouchListener() {
          
                      @Override
          Severity: Minor
          Found in app/src/main/java/ch/epfl/sweng/GyroDraw/home/HomeActivity.java - About 1 hr to fix

            Function functionTimer has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function functionTimer (seconds, state, roomID, isWaiting, call) {
              return new Promise((resolve, reject) => {
                // This represents the maximum time allowed for firebase.
                if (seconds > 300) {
                    return;
            Severity: Minor
            Found in functions/index.js - About 1 hr to fix

              Function joinGame has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              exports.joinGame = functions.https.onCall((data, context) => {
                const id = data.id;
                const username = data.username;
                const league = data.league - 1;
                const gameMode = data.mode;
              Severity: Minor
              Found in functions/index.js - About 1 hr to fix

                Method setLayout has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    @SuppressLint({"NewApi", "ClickableViewAccessibility"})
                    void setLayout(int stars, ShopActivity context) {
                        Resources res = context.getResources();
                        String colorName = color.toString();
                        Typeface typeMuro = TypefaceLibrary.getTypeMuro();
                Severity: Minor
                Found in app/src/main/java/ch/epfl/sweng/GyroDraw/shop/ShopItem.java - About 1 hr to fix

                  Method listenerEventSelector has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private void listenerEventSelector(final View view, int resourceId) {
                          switch (resourceId) {
                              case R.id.drawButton:
                                  ((ImageView) view).setImageResource(R.drawable.draw_button);
                                  launchOnlineGame(NORMAL_MODE);
                  Severity: Minor
                  Found in app/src/main/java/ch/epfl/sweng/GyroDraw/home/HomeActivity.java - About 1 hr to fix

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

                        @Test
                        public void testTextFeedbackGetsDisplayed() {
                            int viewsBefore = paintViewHolder.getChildCount();
                            Item item;
                            do {
                    app/src/androidTest/java/ch/epfl/sweng/GyroDraw/game/drawing/DrawingOfflineActivityWithItemsTest.java on lines 80..93

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

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

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

                    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

                        @Test
                        public void testTextFeedbackGetsDisplayed() {
                            int viewsBefore = paintViewHolder.getChildCount();
                            Item item;
                            do {
                    app/src/androidTest/java/ch/epfl/sweng/GyroDraw/game/drawing/DrawingOnlineItemsActivityTest.java on lines 70..83

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

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

                        @Override
                        protected void onCreate(Bundle savedInstanceState) {
                            super.onCreate(savedInstanceState);
                            overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
                            setContentView(getLayoutId());

                      Method retrieveFinalRanking has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private void retrieveFinalRanking() {
                              FbDatabase.getRoomAttribute(roomId, RANKING,
                                      new OnSuccessValueEventListener() {
                      
                                          @Override
                      Severity: Minor
                      Found in app/src/main/java/ch/epfl/sweng/GyroDraw/game/RankingFragment.java - About 1 hr to fix

                        Method onDataChange has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                @Override
                                public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                                    Integer state = dataSnapshot.getValue(Integer.class);
                                    if (state != null) {
                                        GameStates stateEnum = GameStates.convertValueIntoState(state);

                          Function onInterval has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              function onInterval() {
                          
                                if (stop === true) {
                                  stop = false;
                                  throw new "Timer stopped";
                          Severity: Minor
                          Found in functions/index.js - About 1 hr to fix

                            Method onCreate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                @Override
                                protected void onCreate(Bundle savedInstanceState) {
                                    super.onCreate(savedInstanceState);
                                    overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
                                    setContentView(R.layout.activity_waiting_page);

                              Function updateUser has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function updateUser(userID) {
                                return admin.database().ref("users/").once('value', (snapshot) => {
                                  if(snapshot.hasChild(userID)) {
                                    let newTrophies;
                                    let totalMatches;
                              Severity: Minor
                              Found in functions/index.js - About 1 hr to fix

                                Method convertValueIntoState has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public static GameStates convertValueIntoState(int value) {
                                        GameStates state;
                                        switch (value) {
                                            case 0:
                                                state = HOME_STATE;

                                  Method handleSuccessfulSignIn has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      private void handleSuccessfulSignIn(IdpResponse response) {
                                          assert response != null;
                                  
                                          final String email = response.getEmail();
                                          if (response.isNewUser()) {
                                  Severity: Minor
                                  Found in app/src/main/java/ch/epfl/sweng/GyroDraw/auth/LoginActivity.java - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language