wikimedia/mediawiki-core

View on GitHub
maintenance/language/zhtable/Makefile.py

Summary

Maintainability
F
4 days
Test Coverage

File Makefile.py has 357 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @author Philip
import os
import platform
Severity: Minor
Found in maintenance/language/zhtable/Makefile.py - About 4 hrs to fix

    Function removeRules has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def removeRules(path, table):
        fp = open(path, 'r', encoding='U8')
        texc = list()
        for line in fp:
            elems = line.split('=>')
    Severity: Minor
    Found in maintenance/language/zhtable/Makefile.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 main has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def main():
        # Get Unihan.zip:
        url = 'https://www.unicode.org/Public/%s/ucd/Unihan.zip' % UNIHAN_VER
        han_dest = 'Unihan-%s.zip' % UNIHAN_VER
        download(url, han_dest)
    Severity: Major
    Found in maintenance/language/zhtable/Makefile.py - About 2 hrs to fix

      Function parserCore has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def parserCore(fp, pos, beginmark=None, endmark=None):
          if beginmark and endmark:
              start = False
          else:
              start = True
      Severity: Minor
      Found in maintenance/language/zhtable/Makefile.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 toManyRules has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def toManyRules(src_table):
          tomany = set()
          if pyversion[:1] in ['2']:
              for (f, t) in src_table.iteritems():
                  for i in range(1, len(t)):
      Severity: Minor
      Found in maintenance/language/zhtable/Makefile.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 unihanParser has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def unihanParser(path):
          """ Read Unihan_Variants.txt and parse it. """
          fp = unzip(path, 'Unihan_Variants.txt', 'U8')
          t2s = dict()
          s2t = dict()
      Severity: Minor
      Found in maintenance/language/zhtable/Makefile.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 defaultWordsTable has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def defaultWordsTable(src_wordlist, src_tomany, char_conv_table,
                            char_reconv_table):
          wordlist = list(src_wordlist)
          wordlist.sort(key=lambda w: (len(w), w), reverse=True)
          word_conv_table = {}
      Severity: Minor
      Found in maintenance/language/zhtable/Makefile.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 main has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def main():
          # Get Unihan.zip:
          url = 'https://www.unicode.org/Public/%s/ucd/Unihan.zip' % UNIHAN_VER
          han_dest = 'Unihan-%s.zip' % UNIHAN_VER
          download(url, han_dest)
      Severity: Minor
      Found in maintenance/language/zhtable/Makefile.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 translate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def translate(text, conv_table):
          i = 0
          while i < len(text):
              for j in range(len(text) - i, 0, -1):
                  f = text[i:][:j]
      Severity: Minor
      Found in maintenance/language/zhtable/Makefile.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

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

          if pyversion[:1] in ['2']:
              t2s_1to1 = dict([(f, t) for (f, t) in t2s_1to1.iteritems() if f != t])
          else:
              t2s_1to1 = dict([(f, t) for (f, t) in t2s_1to1.items() if f != t])
      Severity: Major
      Found in maintenance/language/zhtable/Makefile.py and 1 other location - About 5 hrs to fix
      maintenance/language/zhtable/Makefile.py on lines 395..398

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

      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 pyversion[:1] in ['2']:
              s2t_1to1 = dict([(f, t) for (f, t) in s2t_1to1.iteritems() if f != t])
          else:
              s2t_1to1 = dict([(f, t) for (f, t) in s2t_1to1.items() if f != t])
      Severity: Major
      Found in maintenance/language/zhtable/Makefile.py and 1 other location - About 5 hrs to fix
      maintenance/language/zhtable/Makefile.py on lines 389..392

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

      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 pyversion[:1] in ['2']:
              for (f, t) in src_table.iteritems():
                  for i in range(1, len(t)):
                      tomany.add(t[i])
      Severity: Major
      Found in maintenance/language/zhtable/Makefile.py and 1 other location - About 1 hr to fix
      maintenance/language/zhtable/Makefile.py on lines 178..185

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

      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 pyversion[:1] in ['2']:
              for (tmp_f, tmp_t) in table.copy().iteritems():
                  if texcptn.match(tmp_t):
                      table.pop(tmp_f)
      Severity: Minor
      Found in maintenance/language/zhtable/Makefile.py and 1 other location - About 50 mins to fix
      maintenance/language/zhtable/Makefile.py on lines 207..214

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

      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

              s2t_1to1 = dict([(f, t[0]) for (f, t) in s2t_1tomany.items()])
      Severity: Major
      Found in maintenance/language/zhtable/Makefile.py and 3 other locations - About 35 mins to fix
      maintenance/language/zhtable/Makefile.py on lines 334..334
      maintenance/language/zhtable/Makefile.py on lines 335..335
      maintenance/language/zhtable/Makefile.py on lines 337..337

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

      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

              t2s_1to1 = dict([(f, t[0]) for (f, t) in t2s_1tomany.items()])
      Severity: Major
      Found in maintenance/language/zhtable/Makefile.py and 3 other locations - About 35 mins to fix
      maintenance/language/zhtable/Makefile.py on lines 334..334
      maintenance/language/zhtable/Makefile.py on lines 335..335
      maintenance/language/zhtable/Makefile.py on lines 338..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 33.

      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

              t2s_1to1 = dict([(f, t[0]) for (f, t) in t2s_1tomany.iteritems()])
      Severity: Major
      Found in maintenance/language/zhtable/Makefile.py and 3 other locations - About 35 mins to fix
      maintenance/language/zhtable/Makefile.py on lines 335..335
      maintenance/language/zhtable/Makefile.py on lines 337..337
      maintenance/language/zhtable/Makefile.py on lines 338..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 33.

      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

              s2t_1to1 = dict([(f, t[0]) for (f, t) in s2t_1tomany.iteritems()])
      Severity: Major
      Found in maintenance/language/zhtable/Makefile.py and 3 other locations - About 35 mins to fix
      maintenance/language/zhtable/Makefile.py on lines 334..334
      maintenance/language/zhtable/Makefile.py on lines 337..337
      maintenance/language/zhtable/Makefile.py on lines 338..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 33.

      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