Unbabel/OpenKiwi

View on GitHub

Showing 75 of 264 total issues

File predictor_estimator.py has 551 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#  OpenKiwi: Open-Source Machine Translation Quality Estimation
#  Copyright (C) 2019 Unbabel <openkiwi@unbabel.com>
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU Affero General Public License as published
Severity: Major
Found in kiwi/models/predictor_estimator.py - About 1 day to fix

    File predictor_estimator.py has 478 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #  OpenKiwi: Open-Source Machine Translation Quality Estimation
    #  Copyright (C) 2019 Unbabel <openkiwi@unbabel.com>
    #
    #  This program is free software: you can redistribute it and/or modify
    #  it under the terms of the GNU Affero General Public License as published
    Severity: Minor
    Found in kiwi/cli/models/predictor_estimator.py - About 7 hrs to fix

      File metrics.py has 414 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #  OpenKiwi: Open-Source Machine Translation Quality Estimation
      #  Copyright (C) 2019 Unbabel <openkiwi@unbabel.com>
      #
      #  This program is free software: you can redistribute it and/or modify
      #  it under the terms of the GNU Affero General Public License as published
      Severity: Minor
      Found in kiwi/metrics/metrics.py - About 5 hrs to fix

        Function retrieve_predictions has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
        Open

        def retrieve_predictions(pipeline_options, is_wmt18_pred_format):
            pred_files = {target: [] for target in const.TARGETS}
            if pipeline_options.pred_target:
                for pred_file in pipeline_options.pred_target:
                    pred_target = read_file(pred_file)
        Severity: Minor
        Found in kiwi/lib/evaluate.py - 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

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

            def __init__(
                self,
                counter,
                max_size=None,
                min_freq=1,
        Severity: Minor
        Found in kiwi/data/vocabulary.py - About 4 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

        File train.py has 348 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        #  OpenKiwi: Open-Source Machine Translation Quality Estimation
        #  Copyright (C) 2019 Unbabel <openkiwi@unbabel.com>
        #
        #  This program is free software: you can redistribute it and/or modify
        #  it under the terms of the GNU Affero General Public License as published
        Severity: Minor
        Found in kiwi/lib/train.py - About 4 hrs to fix

          File quetch.py has 328 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          #  OpenKiwi: Open-Source Machine Translation Quality Estimation
          #  Copyright (C) 2019 Unbabel <openkiwi@unbabel.com>
          #
          #  This program is free software: you can redistribute it and/or modify
          #  it under the terms of the GNU Affero General Public License as published
          Severity: Minor
          Found in kiwi/cli/models/quetch.py - About 3 hrs to fix

            File evaluate.py has 318 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            #  OpenKiwi: Open-Source Machine Translation Quality Estimation
            #  Copyright (C) 2019 Unbabel <openkiwi@unbabel.com>
            #
            #  This program is free software: you can redistribute it and/or modify
            #  it under the terms of the GNU Affero General Public License as published
            Severity: Minor
            Found in kiwi/lib/evaluate.py - About 3 hrs to fix

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

                  def __init__(
                      self, vocabs, predictor_tgt=None, predictor_src=None, **kwargs
                  ):
              
                      super().__init__(vocabs=vocabs, ConfigCls=EstimatorConfig, **kwargs)
              Severity: Minor
              Found in kiwi/models/predictor_estimator.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

              File quetch.py has 309 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              #  OpenKiwi: Open-Source Machine Translation Quality Estimation
              #  Copyright (C) 2019 Unbabel <openkiwi@unbabel.com>
              #
              #  This program is free software: you can redistribute it and/or modify
              #  it under the terms of the GNU Affero General Public License as published
              Severity: Minor
              Found in kiwi/models/quetch.py - About 3 hrs to fix

                File predictor.py has 299 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                #  OpenKiwi: Open-Source Machine Translation Quality Estimation
                #  Copyright (C) 2019 Unbabel <openkiwi@unbabel.com>
                #
                #  This program is free software: you can redistribute it and/or modify
                #  it under the terms of the GNU Affero General Public License as published
                Severity: Minor
                Found in kiwi/models/predictor.py - About 3 hrs to fix

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

                      def read_tabular_file(file_path, sep='\t', extract_column=None):
                          examples = []
                          line_values = []
                          with open(file_path, 'r', encoding='utf8') as f:
                              num_columns = None
                  Severity: Minor
                  Found in kiwi/data/corpus.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 predict has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def predict(self, batch, class_name=const.BAD, unmask=True):
                          model_out = self(batch)
                          predictions = {}
                          class_index = torch.tensor([const.LABELS.index(class_name)])
                  
                  
                  Severity: Minor
                  Found in kiwi/models/model.py - About 2 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 cache has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def cache(self, name, cache, url=None, max_vectors=None):
                          if self.emb_format in ['polyglot', 'glove']:
                              try:
                                  from polyglot.mapping import Embedding
                              except ImportError:
                  Severity: Minor
                  Found in kiwi/data/vectors.py - About 2 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 __init__ has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def __init__(
                          self,
                          name,
                          model_parsers,
                          options_fn=None,
                  Severity: Minor
                  Found in kiwi/cli/better_argparse.py - About 2 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 forward has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def forward(self, batch):
                          outputs = OrderedDict()
                          contexts_tgt, h_tgt = None, None
                          contexts_src, h_src = None, None
                          if (
                  Severity: Minor
                  Found in kiwi/models/predictor_estimator.py - About 2 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 from_tabular_file has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def from_tabular_file(cls, fields, file_fields, file_path, sep='\t'):
                          """Create a QualityEstimationDataset given paths and fields.
                  
                          Arguments:
                              fields: A dict between field name and field object.
                  Severity: Minor
                  Found in kiwi/data/corpus.py - About 2 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

                  File linear.py has 266 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  #  OpenKiwi: Open-Source Machine Translation Quality Estimation
                  #  Copyright (C) 2019 Unbabel <openkiwi@unbabel.com>
                  #
                  #  This program is free software: you can redistribute it and/or modify
                  #  it under the terms of the GNU Affero General Public License as published
                  Severity: Minor
                  Found in kiwi/cli/models/linear.py - About 2 hrs to fix

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

                        def __init__(
                    Severity: Major
                    Found in kiwi/models/predictor_estimator.py - About 2 hrs to fix

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

                      def run(ModelClass, output_dir, pipeline_options, model_options, splits):
                          model_name = getattr(ModelClass, 'title', ModelClass.__name__)
                          logger.info('Jackknifing with the {} model'.format(model_name))
                      
                          # Data
                      Severity: Minor
                      Found in kiwi/lib/jackknife.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

                      Severity
                      Category
                      Status
                      Source
                      Language