hackedteam/vector-edk

View on GitHub
vector-uefi/fd/efi/StdLib/lib/python.27/gettext.py

Summary

Maintainability
F
1 mo
Test Coverage

File gettext.py has 426 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Internationalization and localization support.

This module provides internationalization (I18N) and localization (L10N)
support for your Python programs by providing an interface to the GNU gettext
message catalog library.
Severity: Minor
Found in vector-uefi/fd/efi/StdLib/lib/python.27/gettext.py - About 6 hrs to fix

    Function _parse has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

        def _parse(self, fp):
            """Override this method to support alternative .mo formats."""
            unpack = struct.unpack
            filename = getattr(fp, 'name', '')
            # Parse the .mo file header, which consists of 5 little endian 32
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/gettext.py - About 5 hrs 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 find has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    def find(domain, localedir=None, languages=None, all=0):
        # Get some reasonable defaults for arguments that were not supplied
        if localedir is None:
            localedir = _default_localedir
        if languages is None:
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/gettext.py - About 3 hrs 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 _expand_lang has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def _expand_lang(locale):
        from locale import normalize
        locale = normalize(locale)
        COMPONENT_CODESET   = 1 << 0
        COMPONENT_TERRITORY = 1 << 1
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/gettext.py - About 2 hrs 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 c2py has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def c2py(plural):
        """Gets a C expression as used in PO files for plural forms and returns a
        Python lambda function that implements an equivalent expression.
        """
        # Security check, allow only the "n" identifier
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/gettext.py - About 1 hr 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 install has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def install(self, unicode=False, names=None):
            import __builtin__
            __builtin__.__dict__['_'] = unicode and self.ugettext or self.gettext
            if hasattr(names, "__contains__"):
                if "gettext" in names:
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/gettext.py - About 1 hr 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 translation has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def translation(domain, localedir=None, languages=None,
                    class_=None, fallback=False, codeset=None):
        if class_ is None:
            class_ = GNUTranslations
        mofiles = find(domain, localedir, languages, all=1)
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/gettext.py - About 1 hr 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 translation has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def translation(domain, localedir=None, languages=None,
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/gettext.py - About 45 mins to fix

      Function ngettext has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def ngettext(self, msgid1, msgid2, n):
              try:
                  tmsg = self._catalog[(msgid1, self.plural(n))]
                  if self._output_charset:
                      return tmsg.encode(self._output_charset)
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/gettext.py - About 45 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 install has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def install(domain, localedir=None, unicode=False, codeset=None, names=None):
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/gettext.py - About 35 mins to fix

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

            def lngettext(self, msgid1, msgid2, n):
                try:
                    tmsg = self._catalog[(msgid1, self.plural(n))]
                    if self._output_charset:
                        return tmsg.encode(self._output_charset)
        Severity: Minor
        Found in vector-uefi/fd/efi/StdLib/lib/python.27/gettext.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

        Avoid too many return statements within this function.
        Open

                        return msgid2
        Severity: Major
        Found in vector-uefi/fd/efi/StdLib/lib/python.27/gettext.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                          return msgid2
          Severity: Major
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/gettext.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return tmsg
            Severity: Major
            Found in vector-uefi/fd/efi/StdLib/lib/python.27/gettext.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                              return msgid1
              Severity: Major
              Found in vector-uefi/fd/efi/StdLib/lib/python.27/gettext.py - About 30 mins to fix

                Function ungettext has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def ungettext(self, msgid1, msgid2, n):
                        try:
                            tmsg = self._catalog[(msgid1, self.plural(n))]
                        except KeyError:
                            if self._fallback:
                Severity: Minor
                Found in vector-uefi/fd/efi/StdLib/lib/python.27/gettext.py - 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

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

                Severity: Major
                Found in vector-uefi/fd/efi/StdLib/lib/python.27/gettext.py and 1 other location - About 1 mo to fix
                AppPkg/Applications/Python/Python-2.7.2/Lib/gettext.py on lines 0..591

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

                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