Unbabel/OpenKiwi

View on GitHub

Showing 81 of 81 total issues

Function __init__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, config: Config, field_encoders: Dict[str, TextEncoder] = None):
        super().__init__()
        self._vocabularies_initialized = False
        self.config = config

Severity: Minor
Found in kiwi/data/encoders/wmt_qe_data_encoder.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 __init__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, config: Config, field_encoders: Dict[str, TextEncoder] = None):
        super().__init__()
        self._vocabularies_initialized = False
        self.config = config

Severity: Minor
Found in kiwi/data/encoders/parallel_data_encoder.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 __init__ has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def __init__(self, input_dim, config):
        super().__init__()
        self.input_dim = input_dim
        self.config = config

Severity: Minor
Found in kiwi/systems/decoders/nuqe.py - About 1 hr to fix

    Function __init__ has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def __init__(self, input_dim, config):
            super().__init__()
            self.input_dim = input_dim
            self.config = config
    
    
    Severity: Minor
    Found in kiwi/systems/decoders/nuqe.py - About 1 hr to fix

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

          def forward(self, batch_inputs):
              target_emb = self.embeddings[const.TARGET](batch_inputs[const.TARGET])
              source_emb = self.embeddings[const.SOURCE](batch_inputs[const.SOURCE])
      
              if const.TARGET_POS in self.embeddings:
      Severity: Minor
      Found in kiwi/systems/encoders/quetch.py - About 1 hr to fix

        Function make_predictions has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def make_predictions(
        Severity: Major
        Found in kiwi/lib/predict.py - About 1 hr to fix

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

                  for p in self.parameters():
                      if len(p.shape) > 1:
                          nn.init.xavier_uniform_(p)
          Severity: Major
          Found in kiwi/modules/sentence_level_output.py and 2 other locations - About 55 mins to fix
          kiwi/modules/sentence_level_output.py on lines 66..68
          kiwi/modules/sentence_level_output.py on lines 123..125

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

          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

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

                  for p in self.parameters():
                      if len(p.shape) > 1:
                          nn.init.xavier_uniform_(p)
          Severity: Major
          Found in kiwi/modules/sentence_level_output.py and 2 other locations - About 55 mins to fix
          kiwi/modules/sentence_level_output.py on lines 91..93
          kiwi/modules/sentence_level_output.py on lines 123..125

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

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

              def __init__(
                  self,
                  config,
                  data_config: WMTQEDataset.Config = None,
                  module_dict: Dict[str, Any] = None,
          Severity: Minor
          Found in kiwi/systems/bert.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

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

              def __init__(
                  self, vocabs: Dict[str, Vocabulary], config: Config, pre_load_model: bool = True
              ):
                  super().__init__(config=config)
          
          
          Severity: Minor
          Found in kiwi/systems/encoders/xlmroberta.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

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

              def __init__(
                  self,
                  config,
                  data_config: WMTQEDataset.Config = None,
                  module_dict: Dict[str, Any] = None,
          Severity: Minor
          Found in kiwi/systems/xlm.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

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

              def forward(self, features, batch_inputs):
                  output_features = OrderedDict()
          
                  if const.TARGET in features:
                      features_tensor = features[const.TARGET]
          Severity: Minor
          Found in kiwi/systems/decoders/estimator.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

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

          def to_numeric_values(
              predictions: Union[str, List[str], List[List[str]]]
          ) -> Union[int, float, List[int], List[float], List[List[int]], List[List[float]]]:
              """Convert text labels or string probabilities (for BAD) to int or float values,
              respectively."""
          Severity: Minor
          Found in kiwi/lib/evaluate.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

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

                  for p in self.parameters():
                      if len(p.shape) > 1:
                          nn.init.xavier_uniform_(p)
          Severity: Major
          Found in kiwi/modules/sentence_level_output.py and 2 other locations - About 55 mins to fix
          kiwi/modules/sentence_level_output.py on lines 66..68
          kiwi/modules/sentence_level_output.py on lines 91..93

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

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

              def __init__(
                  self,
                  config,
                  data_config: WMTQEDataset.Config = None,
                  module_dict: Dict[str, Any] = None,
          Severity: Minor
          Found in kiwi/systems/predictor_estimator.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

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

              def __init__(
                  self,
                  config,
                  data_config: WMTQEDataset.Config = None,
                  module_dict: Dict[str, Any] = None,
          Severity: Minor
          Found in kiwi/systems/xlmroberta.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

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

          def to_numeric_binary_labels(
              predictions: Union[
                  str, float, List[str], List[List[str]], List[float], List[List[float]]
              ],
              threshold: float = 0.5,
          Severity: Minor
          Found in kiwi/lib/evaluate.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

          Function fit_vocab has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def fit_vocab(
          Severity: Major
          Found in kiwi/systems/encoders/xlm.py - About 50 mins to fix

            Function feedforward has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def feedforward(
            Severity: Major
            Found in kiwi/modules/common/feedforward.py - About 50 mins to fix

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

                  def __init__(
              Severity: Major
              Found in kiwi/systems/encoders/predictor.py - About 50 mins to fix
                Severity
                Category
                Status
                Source
                Language