Narazaka/shiori_converter.js

View on GitHub

Showing 33 of 33 total issues

Function request3to2 has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

  static request3to2(request: ShioriJK.Message.Request) {
    /*
    SHIORI/2.x互換変換
    - GET : Sentence : OnCommunicate はGET Sentence SHIORI/2.3に変換され、ヘッダの位置が変更されます。
    - GET : TEACH : OnTeach はTEACH SHIORI/2.4に変換され、ヘッダの位置が変更されます。
Severity: Minor
Found in lib/shiori_converter.ts - About 6 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 request3to2 has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  static request3to2(request: ShioriJK.Message.Request) {
    /*
    SHIORI/2.x互換変換
    - GET : Sentence : OnCommunicate はGET Sentence SHIORI/2.3に変換され、ヘッダの位置が変更されます。
    - GET : TEACH : OnTeach はTEACH SHIORI/2.4に変換され、ヘッダの位置が変更されます。
Severity: Major
Found in lib/shiori_converter.ts - About 2 hrs to fix

    File shiori_converter.ts has 260 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import * as ShioriJK from "shiorijk";
    
    /**
     * SHIORI/2.x/3.x/4.x Converter
     */
    Severity: Minor
    Found in lib/shiori_converter.ts - About 2 hrs to fix

      Function response2to3 has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static response2to3(request: ShioriJK.Message.Request, response: ShioriJK.Message.Response) {
          const convRequest = ShioriConverter.requestTo(request, "2.6");
          let valueHeaderName: ShioriConverter.Shiori2ValueHeader;
          if (convRequest instanceof ShioriJK.Message.Request) {
            switch (convRequest.request_line.method) {
      Severity: Minor
      Found in lib/shiori_converter.ts - About 1 hr to fix

        Function responseTo has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          static responseTo(
            request: ShioriJK.Message.Request,
            response: ShioriJK.Message.Response,
            version: ShioriConverter.ShioriVersion,
          ) {
        Severity: Minor
        Found in lib/shiori_converter.ts - 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

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

          static response3to4(
            // eslint-disable-next-line @typescript-eslint/no-unused-vars
            _request: ShioriJK.Message.Request,
            // eslint-disable-next-line @typescript-eslint/no-unused-vars
            _response: ShioriJK.Message.Response,
        Severity: Major
        Found in lib/shiori_converter.ts and 2 other locations - About 1 hr to fix
        lib/shiori_converter.ts on lines 269..276
        lib/shiori_converter.ts on lines 294..301

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

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

          static response3to2(
            // eslint-disable-next-line @typescript-eslint/no-unused-vars
            _request: ShioriJK.Message.Request,
            // eslint-disable-next-line @typescript-eslint/no-unused-vars
            _response: ShioriJK.Message.Response,
        Severity: Major
        Found in lib/shiori_converter.ts and 2 other locations - About 1 hr to fix
        lib/shiori_converter.ts on lines 269..276
        lib/shiori_converter.ts on lines 365..372

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

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

          static response4to3(
            // eslint-disable-next-line @typescript-eslint/no-unused-vars
            _request: ShioriJK.Message.Request,
            // eslint-disable-next-line @typescript-eslint/no-unused-vars
            _response: ShioriJK.Message.Response,
        Severity: Major
        Found in lib/shiori_converter.ts and 2 other locations - About 1 hr to fix
        lib/shiori_converter.ts on lines 294..301
        lib/shiori_converter.ts on lines 365..372

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

        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 requestTo has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          static requestTo(request: ShioriJK.Message.Request, version: ShioriConverter.ShioriVersion) {
            if (!request) throw new ShioriConverter.RequestNotSetError();
            if ((request.request_line.version as string) === "4.0") {
              if (version === "4.0") {
                return request;
        Severity: Minor
        Found in lib/shiori_converter.ts - 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 response2to3 has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          static response2to3(request: ShioriJK.Message.Request, response: ShioriJK.Message.Response) {
            const convRequest = ShioriConverter.requestTo(request, "2.6");
            let valueHeaderName: ShioriConverter.Shiori2ValueHeader;
            if (convRequest instanceof ShioriJK.Message.Request) {
              switch (convRequest.request_line.method) {
        Severity: Minor
        Found in lib/shiori_converter.ts - 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 responseTo has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          static responseTo(
            request: ShioriJK.Message.Request,
            response: ShioriJK.Message.Response,
            version: ShioriConverter.ShioriVersion,
          ) {
        Severity: Minor
        Found in lib/shiori_converter.ts - About 1 hr to fix

          Function requestTo has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            static requestTo(request: ShioriJK.Message.Request, version: ShioriConverter.ShioriVersion) {
              if (!request) throw new ShioriConverter.RequestNotSetError();
              if ((request.request_line.version as string) === "4.0") {
                if (version === "4.0") {
                  return request;
          Severity: Minor
          Found in lib/shiori_converter.ts - About 1 hr to fix

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

              static method3to2(request: ShioriJK.Message.Request) {
                const id = request.headers.header.ID;
                if (id === "version") {
                  return "GET Version";
                }
            Severity: Minor
            Found in lib/shiori_converter.ts - 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

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

              static request3to4(_request: ShioriJK.Message.Request): ShioriJK.Message.Request {
                throw new ShioriConverter.NotImplementedError();
              }
            Severity: Minor
            Found in lib/shiori_converter.ts and 1 other location - About 50 mins to fix
            lib/shiori_converter.ts on lines 90..92

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

            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

              static request4to3(_request: ShioriJK.Message.Request): ShioriJK.Message.Request {
                throw new ShioriConverter.NotImplementedError();
              }
            Severity: Minor
            Found in lib/shiori_converter.ts and 1 other location - About 50 mins to fix
            lib/shiori_converter.ts on lines 250..252

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

            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

                } else if (method === "TRANSLATE Sentence") {
                  // SHIORI/2.6
                  headers.header.Sentence = request.headers.header.Reference0;
                  // ref0のためにヘッダをずらす
                  referenceOffset = -1;
            Severity: Minor
            Found in lib/shiori_converter.ts and 1 other location - About 35 mins to fix
            lib/shiori_converter.ts on lines 179..211

            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

              static request4to2(request: ShioriJK.Message.Request) {
                return ShioriConverter.request3to2(ShioriConverter.request4to3(request));
              }
            Severity: Minor
            Found in lib/shiori_converter.ts and 1 other location - About 35 mins to fix
            lib/shiori_converter.ts on lines 259..261

            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

              static request2to4(request: ShioriJK.Message.Request) {
                return ShioriConverter.request3to4(ShioriConverter.request2to3(request));
              }
            Severity: Minor
            Found in lib/shiori_converter.ts and 1 other location - About 35 mins to fix
            lib/shiori_converter.ts on lines 99..101

            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

                } else if (method === "TEACH") {
                  // SHIORI/2.4
                  headers.header.Word = request.headers.header.Reference0;
                  // ref0のためにヘッダをずらす
                  referenceOffset = -1;
            Severity: Minor
            Found in lib/shiori_converter.ts and 1 other location - About 35 mins to fix
            lib/shiori_converter.ts on lines 203..211

            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

            Avoid too many return statements within this function.
            Open

                  return ShioriConverter.request2to4(request);
            Severity: Major
            Found in lib/shiori_converter.ts - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language