gyrodraw/GyroDraw

View on GitHub

Showing 34 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

                    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

                    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

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

                                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 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);

                                    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();
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language