sarumaj/go-kakasi

View on GitHub

Showing 13 of 13 total issues

Method Kakasi.Convert has a Cognitive Complexity of 51 (exceeds 20 allowed). Consider refactoring.
Open

func (k Kakasi) Convert(text string) (IConvertedSlice, error) {
    if len([]rune(text)) == 0 {
        return IConvertedSlice{{}}, nil
    }

Severity: Minor
Found in kakasi.go - 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

ch has 37 methods (exceeds 20 allowed). Consider refactoring.
Open

type ch struct{}
Severity: Minor
Found in internal/properties/ch.go - About 4 hrs to fix

    Method Kakasi.Convert has 97 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (k Kakasi) Convert(text string) (IConvertedSlice, error) {
        if len([]rune(text)) == 0 {
            return IConvertedSlice{{}}, nil
        }
    
    
    Severity: Major
    Found in kakasi.go - About 2 hrs to fix

      Method convertTables.Latin1Table has 97 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (c convertTables) Latin1Table() map[rune]string {
          return map[rune]string{
              0x00A1: "!",        // inverted exclamation mark
              0x00A2: "cent",     // cent mark
              0x00A3: "GBP",      // pound mark
      Severity: Major
      Found in internal/properties/convert_tables.go - About 2 hrs to fix

        Method convertTables.CyrillicTable has 84 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (convertTables) CyrillicTable() map[rune]string {
            return map[rune]string{
                0x0400: "E",   // Ѐ
                0x0401: "E",   // Ё
                0x0402: "Dj",  // Ђ
        Severity: Major
        Found in internal/properties/convert_tables.go - About 2 hrs to fix

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

          func (c convertTables) AlphaTable1() map[rune]string {
              return map[rune]string{
                  ' ':  "\u3000",
                  '!':  "\uFF01",
                  '"':  "\uFF02",
          Severity: Major
          Found in internal/properties/convert_tables.go and 1 other location - About 1 hr to fix
          internal/properties/convert_tables.go on lines 276..312

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

          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

          func (convertTables) SymbolTable1() map[rune]string {
              return map[rune]string{
                  0x3000: " ",
                  0x3001: ",",
                  0x3002: ".",
          Severity: Major
          Found in internal/properties/convert_tables.go and 1 other location - About 1 hr to fix
          internal/properties/convert_tables.go on lines 14..50

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

          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

          func (convertTables) SymbolTable3() map[rune]string {
              return map[rune]string{
                  0x0391: "Alpha",
                  0x0392: "Beta",
                  0x0393: "Gamma",
          Severity: Major
          Found in internal/properties/convert_tables.go and 1 other location - About 1 hr to fix
          internal/properties/convert_tables.go on lines 375..403

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

          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

          func (convertTables) SymbolTable4() map[rune]string {
              return map[rune]string{
                  0x03B1: "alpha",
                  0x03B2: "beta",
                  0x03B3: "gamma",
          Severity: Major
          Found in internal/properties/convert_tables.go and 1 other location - About 1 hr to fix
          internal/properties/convert_tables.go on lines 342..370

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

          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

              switch conf.Mode {
          
              case Mode_a:
                  var err error
          
          
          Severity: Major
          Found in internal/script/kata.go and 1 other location - About 1 hr to fix
          internal/script/hira.go on lines 88..118

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

          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

              switch conf.Mode {
          
              case Mode_a:
                  var err error
          
          
          Severity: Major
          Found in internal/script/hira.go and 1 other location - About 1 hr to fix
          internal/script/kata.go on lines 162..192

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

          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 Generate has 7 return statements (exceeds 4 allowed).
          Open

          func Generate(dst, indent string) error {
              for tgt, src := range lookupMapResources {
                  m, err := makeLookupMap(src)
                  if err != nil {
                      return err
          Severity: Major
          Found in internal/codegen/codegen.go - About 45 mins to fix

            Method Kata.convertH has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
            Open

            func (k Kata) convertH(text string) (string, int, error) {
                var converted string
                var max_length int
            
                var diff rune = 0x30A1 - 0x3041
            Severity: Minor
            Found in internal/script/kata.go - 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