ConnectOut-sdp/sdp2023

View on GitHub

Showing 13 of 28 total issues

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

      const twoHoursBeforeJob = admin.pubsub.schedule(new Date(twoHoursBefore))
          .topic(`event_${eventId}`)
          .message({
            notification: {
              title: `Upcoming event: ${eventData.title}`,
Severity: Major
Found in functions/index.js and 1 other location - About 3 hrs to fix
functions/index.js on lines 38..46

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

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

      const eventTimeJob = admin.pubsub.schedule(new Date(eventTime))
          .topic(`event_${eventId}`)
          .message({
            notification: {
              title: `Upcoming event: ${eventData.title}`,
Severity: Major
Found in functions/index.js and 1 other location - About 3 hrs to fix
functions/index.js on lines 28..36

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

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

    .onCreate((snapshot, context) => {
      const eventData = snapshot.val();
      const eventId = context.params.eventId;

      // Get the time of the event and calculate the times for the reminders
Severity: Minor
Found in functions/index.js - About 1 hr to fix

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

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_event_creator);
    
    

      Method updateEventView has 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          private void updateEventView(Event event,
                                       TextView title,
                                       TextView description,
                                       Button joinBtn,
                                       Button interestedBtn,

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

                    } else {
                        mapButton.setChecked(false);
                        listButton.setTextColor(Color.WHITE);
                        mapButton.setTextColor(Color.BLACK);
                        listAddButton.setVisibility(View.VISIBLE);
        app/src/main/java/com/sdpteam/connectout/event/nearbyEvents/EventsFragment.java on lines 66..73

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

        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

                    if (R.id.map_switch_button == isChecked) {
                        listButton.setChecked(false);
                        listButton.setTextColor(Color.BLACK);
                        mapButton.setTextColor(Color.WHITE);
                        mapAddButton.setVisibility(View.VISIBLE);
        app/src/main/java/com/sdpteam/connectout/event/nearbyEvents/EventsFragment.java on lines 73..80

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

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

            public static boolean editProfileValidation(EditText nameInput, EditText emailInput, EditText bioInput, RadioButton male, RadioButton female, RadioButton other) {

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

              @Override
              public void updateDataView(View rootView) {
                  eventViewModel.refreshEvent();
                  eventViewModel.getEventLiveData().observe(getViewLifecycleOwner(), this::showEventOnMap);
          
          
          app/src/main/java/com/sdpteam/connectout/event/nearbyEvents/map/EventsMapViewFragment.java on lines 32..40

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

          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

              @Override
              public void updateDataView(View rootView) {
                  eventsViewModel.refreshEvents();
          
                  eventsViewModel.getEventListLiveData().observe(getViewLifecycleOwner(), this::showEventsOnMap);
          app/src/main/java/com/sdpteam/connectout/event/viewer/EventMapViewFragment.java on lines 23..30

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

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

              public void setUpListAdapter(Function<FirebaseListOptions.Builder<ChatMessage>, FirebaseListOptions.Builder<ChatMessage>> setLayout,
                                           Function<FirebaseListOptions.Builder<ChatMessage>, FirebaseListOptions.Builder<ChatMessage>> setLifecycleOwner,
                                           BiConsumer<View, ChatMessage> populateView,
                                           Consumer<ListAdapter> setAdapter,
                                           String chatId) {
          Severity: Minor
          Found in app/src/main/java/com/sdpteam/connectout/chat/ChatViewModel.java - About 35 mins to fix

            Method onViewCreated has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                @Override
                public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
                    super.onViewCreated(view, savedInstanceState);
            
                    Button ratingEditButton = view.findViewById(R.id.buttonRatingEditProfile);
            Severity: Minor
            Found in app/src/main/java/com/sdpteam/connectout/profile/ProfileFragment.java - About 25 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 generateQRCode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public static Bitmap generateQRCode(String data) throws IllegalArgumentException {
                    if (data == null || data.isEmpty()) {
                        throw new IllegalArgumentException("Data cannot be null or empty");
                    }
            
            
            Severity: Minor
            Found in app/src/main/java/com/sdpteam/connectout/QrCode/QRcodeGenerator.java - About 25 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

            Severity
            Category
            Status
            Source
            Language