Unbabel/OpenKiwi

View on GitHub

Showing 233 of 261 total issues

Function decode_mira has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def decode_mira(
Severity: Minor
Found in kiwi/models/linear/structured_decoder.py - About 35 mins to fix

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

        def __init__(
    Severity: Minor
    Found in kiwi/metrics/metrics.py - About 35 mins to fix

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

          def __init__(self, name, pipeline, options_fn, api_module, title=None):
      Severity: Minor
      Found in kiwi/cli/better_argparse.py - About 35 mins to fix

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

            def __init__(
        Severity: Minor
        Found in kiwi/trainers/trainer.py - About 35 mins to fix

          Function setup has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def setup(output_dir, seed=42, gpu_id=None, debug=False, quiet=False):
          Severity: Minor
          Found in kiwi/lib/train.py - About 35 mins to fix

            Function merge_vocabularies has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def merge_vocabularies(vocab_a, vocab_b, max_size=None, vectors=None, **kwargs):
            Severity: Minor
            Found in kiwi/data/vocabulary.py - About 35 mins to fix

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

                  def forward(self, batch):
                      assert self.is_built
              
                      if self.config.predict_source:
                          align_side = const.SOURCE_TAGS
              Severity: Minor
              Found in kiwi/models/nuqe.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

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

              def retrieve_trainer(
                  ModelClass, pipeline_options, model_options, vocabs, output_dir, device_id
              ):
                  """
                  Creates a Trainer object with an associated model.
              Severity: Minor
              Found in kiwi/lib/train.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

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

              def configure_logging(output_dir=None, debug=False, quiet=False):
                  """
                  Configure the logger. Sets up the log format, logging level
                  and output directory of logging.
              
              
              Severity: Minor
              Found in kiwi/lib/utils.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

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

                  def forward(self, batch):
                      assert self.is_built
              
                      if self.config.predict_source:
                          align_side = const.SOURCE_TAGS
              Severity: Minor
              Found in kiwi/models/quetch.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

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

              def build_vocabulary(fields_vocab_options, *datasets):
                  fields = {}
                  for dataset in datasets:
                      fields.update(dataset.fields)
              
              
              Severity: Minor
              Found in kiwi/data/utils.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

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

                      if self.config.binary_level:
                          loss_bin = self.binary_loss(model_out, batch)
                          loss_dict[const.BINARY] = loss_bin
              Severity: Minor
              Found in kiwi/models/predictor_estimator.py and 1 other location - About 35 mins to fix
              kiwi/models/predictor_estimator.py on lines 503..505

              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

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

              def map_alignments_to_target(src2tgt_alignments, target_length=None):
                  """Maps a target index to a list of source indexes.
              
                  Args:
                      src2tgt_alignments (list): list of tuples with source, target indexes.
              Severity: Minor
              Found in kiwi/models/utils.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

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

                  def run(self, dataset, batch_size=1):
                      iterator = build_bucket_iterator(
                          dataset, self._device, batch_size, is_train=False
                      )
                      self.model.eval()
              Severity: Minor
              Found in kiwi/predictors/predictor.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

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

              def build_label_field(postprocessing=None):
                  return SequenceLabelsField(
                      classes=const.LABELS,
                      tokenize=tokenizer,
                      pad_token=const.PAD,
              Severity: Minor
              Found in kiwi/data/fieldsets/predictor.py and 1 other location - About 35 mins to fix
              kiwi/data/fieldsets/predictor_estimator.py on lines 39..43

              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

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

              def build_label_field(postprocessing=None):
                  return SequenceLabelsField(
                      classes=const.LABELS,
                      tokenize=tokenizer,
                      pad_token=const.PAD,
              Severity: Minor
              Found in kiwi/data/fieldsets/predictor_estimator.py and 1 other location - About 35 mins to fix
              kiwi/data/fieldsets/predictor.py on lines 37..41

              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

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

                              if (
                                  fine_to_coarse[predictions[j]]
                                  == fine_to_coarse[instance.sentence_word_labels[j]]
              Severity: Minor
              Found in kiwi/models/linear_word_qe_classifier.py and 1 other location - About 35 mins to fix
              kiwi/models/linear_word_qe_classifier.py on lines 323..325

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

                              if j == 0:
                                  previous_source_word = "<s>"
                                  # previous_source_tag = "<s>"
                              else:
                                  previous_source_word = source_words[j - 1]
              Severity: Minor
              Found in kiwi/models/linear/linear_word_qe_sentence.py and 1 other location - About 35 mins to fix
              kiwi/models/linear/linear_word_qe_sentence.py on lines 170..174

              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

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

                  fs.add(
                      name=const.ALIGNMENTS,
                      field=AlignmentField(tokenize=align_tokenizer, use_vocab=False),
                      file_option_suffix='_alignments',
                      required=Fieldset.ALL,
              Severity: Minor
              Found in kiwi/data/fieldsets/linear.py and 1 other location - About 35 mins to fix
              kiwi/data/fieldsets/quetch.py on lines 69..73

              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

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

                              if (
                                  fine_to_coarse[predictions[j]]
                                  == fine_to_coarse[instance.sentence_word_labels[j]]
              Severity: Minor
              Found in kiwi/models/linear_word_qe_classifier.py and 1 other location - About 35 mins to fix
              kiwi/models/linear_word_qe_classifier.py on lines 329..331

              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

              Severity
              Category
              Status
              Source
              Language