mangroveorg/datawinners

View on GitHub
datawinners/entity/view/send_sms.py

Summary

Maintainability
C
1 day
Test Coverage

Function _get_all_contacts_details_with_mobile_number has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def _get_all_contacts_details_with_mobile_number(dbm, search_parameters, failed_numbers):
    short_codes = []
    search_parameters['response_fields'] = ['short_code', 'name', 'mobile_number']
    search_results = get_all_datasenders_search_results(dbm, search_parameters)
    mobile_numbers, contact_display_list = [], []
Severity: Minor
Found in datawinners/entity/view/send_sms.py - About 55 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

Function _log_poll_questionnaire_sent_messages has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def _log_poll_questionnaire_sent_messages(self, dbm, organization, organization_setting, request, sms_text, current_project_id, failed_numbers):
Severity: Major
Found in datawinners/entity/view/send_sms.py - About 50 mins to fix

    Function _save_sent_message_info has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def _save_sent_message_info(self, org_id, sent_on, sms_text, to_mobile_numbers, from_mobile_numbers, questionnaire_name):
    Severity: Minor
    Found in datawinners/entity/view/send_sms.py - About 45 mins to fix

      Function get_name_short_code_mobile_numbers_for_contacts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_name_short_code_mobile_numbers_for_contacts(dbm, poll_recipients, failed_numbers):
          short_codes = []
          poll_recipients = ast.literal_eval(poll_recipients)
          mobile_numbers = []
          contact_dict_list = []
      Severity: Minor
      Found in datawinners/entity/view/send_sms.py - 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

      def _get_all_contacts_mobile_numbers(dbm, search_parameters):
          search_parameters['response_fields'] = ['mobile_number']
          search_results = get_all_datasenders_search_results(dbm, search_parameters)
          return [safe_getattr(item, 'mobile_number')[0] for item in search_results.hits]
      Severity: Major
      Found in datawinners/entity/view/send_sms.py and 1 other location - About 2 hrs to fix
      datawinners/search/all_datasender_search.py on lines 147..150

      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

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

              questionnaire_names = map(lambda item: lowercase_and_strip_accents(item),
                                            json.loads(request.POST['questionnaire-names']))
      Severity: Major
      Found in datawinners/entity/view/send_sms.py and 2 other locations - About 40 mins to fix
      datawinners/entity/view/send_sms.py on lines 63..64
      datawinners/entity/view/send_sms.py on lines 178..179

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

      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

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

                  questionnaire_names = map(lambda item: lowercase_and_strip_accents(item),
                                            json.loads(request.POST['questionnaire-names']))
      Severity: Major
      Found in datawinners/entity/view/send_sms.py and 2 other locations - About 40 mins to fix
      datawinners/entity/view/send_sms.py on lines 38..39
      datawinners/entity/view/send_sms.py on lines 178..179

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

      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

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

          questionnaire_names = map(lambda item: lowercase_and_strip_accents(item),
                                    json.loads(request.POST['questionnaire-names']))
      Severity: Major
      Found in datawinners/entity/view/send_sms.py and 2 other locations - About 40 mins to fix
      datawinners/entity/view/send_sms.py on lines 38..39
      datawinners/entity/view/send_sms.py on lines 63..64

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

      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

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

                  numbers = map(lambda i: i.strip(), request.POST['others'].split(","))
      Severity: Minor
      Found in datawinners/entity/view/send_sms.py and 1 other location - About 40 mins to fix
      datawinners/entity/view/send_sms.py on lines 28..28

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

      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

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

                  numbers = map(lambda i: i.strip(), request.POST['others'].split(","))
      Severity: Minor
      Found in datawinners/entity/view/send_sms.py and 1 other location - About 40 mins to fix
      datawinners/entity/view/send_sms.py on lines 72..72

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

      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

      There are no issues that match your filters.

      Category
      Status