Net-ng/kansha

View on GitHub
kansha/user/user_profile.py

Summary

Maintainability
F
3 days
Test Coverage

File user_profile.py has 271 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding:utf-8 -*-
#--
# Copyright (c) 2012-2014 Net-ng.
# All rights reserved.
#
Severity: Minor
Found in kansha/user/user_profile.py - About 2 hrs to fix

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

        def commit(self, application_url):
            """ Commit method
    
            If email changes, send confirmation mail to user
            If password changes, check passwords rules
    Severity: Minor
    Found in kansha/user/user_profile.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

    Avoid deeply nested control flow statements.
    Open

                        with h.select().action(self.language).error(self.language.error):
                            for (id, lang) in LANGUAGES.items():
                                if self.language() == id:
                                    h << h.option(lang, value=id, selected='')
                                else:
    Severity: Major
    Found in kansha/user/user_profile.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if hasattr(self.password_repeat, 'info'):
                              h << h.span(
                                  self.password_repeat.info, class_='info-message')
                      with h.li:
      Severity: Major
      Found in kansha/user/user_profile.py - About 45 mins to fix

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

            def __init__(self, app_title, app_banner, theme, target, assets_manager_service, mail_sender_service):
        Severity: Minor
        Found in kansha/user/user_profile.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if hasattr(self.email_to_confirm, 'info'):
                                  h << h.span(
                                      self.email_to_confirm.info, class_='info-message')
                          with h.li(h.label(_('Language'))):
          Severity: Major
          Found in kansha/user/user_profile.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if picture:
                                    with h.label(for_='picture'):
                                        h << h.img(
                                            src=self.target.get_picture(), class_='avatar big')
                                h << h.input(type='file', id='picture').action(self.set_picture)\
            Severity: Major
            Found in kansha/user/user_profile.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  with h.select().action(self.language).error(self.language.error):
                                      for (id, lang) in LANGUAGES.items():
                                          if self.language() == id:
                                              h << h.option(_(lang), value=id, selected='')
                                          else:
              Severity: Major
              Found in kansha/user/user_profile.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    with h.li:
                                        h << (h.label(_('Picture')))
                                        h << h.div(
                                            h.img(src=self.target.picture, class_='avatar big'))
                
                
                Severity: Major
                Found in kansha/user/user_profile.py - About 45 mins to fix

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

                      def __init__(self, app_title, app_banner, theme, target, *args):
                  Severity: Minor
                  Found in kansha/user/user_profile.py - About 35 mins to fix

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

                    def render(self, h, comp, *args):
                        h.head.css_url('css/themes/home.css?v=2c')
                        h.head.css_url('css/themes/%s/home.css?v=2c' % self.theme)
                    
                        with h.div:
                    Severity: Minor
                    Found in kansha/user/user_profile.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

                                    with h.li:
                                        h << (h.label(_('New password')),
                                              h.input(type='password').action(self.password).error(self.password.error))
                    Severity: Major
                    Found in kansha/user/user_profile.py and 1 other location - About 2 hrs to fix
                    kansha/user/user_profile.py on lines 319..322

                    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

                                    with h.li:
                                        h << (h.label(_('Repeat new password')),
                                              h.input(type='password').action(self.password_repeat)
                                              .error(self.password_repeat.error))
                    Severity: Major
                    Found in kansha/user/user_profile.py and 1 other location - About 2 hrs to fix
                    kansha/user/user_profile.py on lines 316..318

                    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 4 locations. Consider refactoring.
                    Open

                                    with h.li:
                                        h << (h.label(_('Username')),
                                              h.input(type='text', disabled=True, value=self.username()))
                    Severity: Major
                    Found in kansha/user/user_profile.py and 3 other locations - About 1 hr to fix
                    kansha/user/user_profile.py on lines 83..85
                    kansha/user/user_profile.py on lines 86..88
                    kansha/user/user_profile.py on lines 277..279

                    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 4 locations. Consider refactoring.
                    Open

                                    with h.li:
                                        h << (h.label(_('Fullname')),
                                              h.input(type='text', disabled=True, value=self.fullname()))
                    Severity: Major
                    Found in kansha/user/user_profile.py and 3 other locations - About 1 hr to fix
                    kansha/user/user_profile.py on lines 80..82
                    kansha/user/user_profile.py on lines 86..88
                    kansha/user/user_profile.py on lines 277..279

                    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 4 locations. Consider refactoring.
                    Open

                                    with h.li:
                                        h << (h.label(_('Username')),
                                              h.input(type='text', readonly=True, value=self.username()))
                    Severity: Major
                    Found in kansha/user/user_profile.py and 3 other locations - About 1 hr to fix
                    kansha/user/user_profile.py on lines 80..82
                    kansha/user/user_profile.py on lines 83..85
                    kansha/user/user_profile.py on lines 86..88

                    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 4 locations. Consider refactoring.
                    Open

                                    with h.li:
                                        h << (h.label(_('Email')),
                                              h.input(type='text', disabled=True, value=self.email()))
                    Severity: Major
                    Found in kansha/user/user_profile.py and 3 other locations - About 1 hr to fix
                    kansha/user/user_profile.py on lines 80..82
                    kansha/user/user_profile.py on lines 83..85
                    kansha/user/user_profile.py on lines 277..279

                    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

                    @peak.rules.when(get_userform, """source != 'application'""")
                    def get_userform(app_title, app_banner, theme, source):
                        """ User form for application user
                        """
                        def factory_compatible_with_services(target, services_service):
                    Severity: Major
                    Found in kansha/user/user_profile.py and 1 other location - About 1 hr to fix
                    kansha/user/user_profile.py on lines 331..338

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

                    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

                    @peak.rules.when(get_userform, """source == 'application'""")
                    def get_userform(app_title, app_banner, theme, source):
                        """ User form for application user
                        """
                        def factory_compatible_with_services(target, services_service):
                    Severity: Major
                    Found in kansha/user/user_profile.py and 1 other location - About 1 hr to fix
                    kansha/user/user_profile.py on lines 345..352

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

                    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 hasattr(self.email_to_confirm, 'info'):
                                            h << h.span(
                                                self.email_to_confirm.info, class_='info-message')
                    Severity: Minor
                    Found in kansha/user/user_profile.py and 1 other location - About 40 mins to fix
                    kansha/user/user_profile.py on lines 313..315

                    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

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

                                        if hasattr(self.password_repeat, 'info'):
                                            h << h.span(
                                                self.password_repeat.info, class_='info-message')
                    Severity: Minor
                    Found in kansha/user/user_profile.py and 1 other location - About 40 mins to fix
                    kansha/user/user_profile.py on lines 286..288

                    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