Unbabel/OpenKiwi

View on GitHub

Showing 78 of 81 total issues

File search.py has 558 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#  OpenKiwi: Open-Source Machine Translation Quality Estimation
#  Copyright (C) 2020 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/lib/search.py - About 1 day to fix

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

    def run(config: Configuration) -> MetricsReport:
        """Runs the evaluation pipeline for evaluating a model's predictions. Essentially
        calculating metrics using `gold_targets` and `prediction_files`.
    
        Refer to configuration for a list of available options for this pipeline.
    Severity: Minor
    Found in kiwi/lib/evaluate.py - About 1 day 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 qe_system.py has 507 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #  OpenKiwi: Open-Source Machine Translation Quality Estimation
    #  Copyright (C) 2020 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/systems/qe_system.py - About 1 day to fix

      File quality_estimation.py has 430 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #  OpenKiwi: Open-Source Machine Translation Quality Estimation
      #  Copyright (C) 2020 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/systems/outputs/quality_estimation.py - About 6 hrs to fix

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

        #  OpenKiwi: Open-Source Machine Translation Quality Estimation
        #  Copyright (C) 2020 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 6 hrs to fix

          Function __init__ has a Cognitive Complexity of 36 (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 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

          File xlm.py has 388 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          #  OpenKiwi: Open-Source Machine Translation Quality Estimation
          #  Copyright (C) 2020 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/systems/encoders/xlm.py - About 5 hrs to fix

            Function build has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
            Open

                def build(
                    config: Config, directory=None, train=False, valid=False, test=False, split=0
                ):
                    """Build training, validation, and test datasets.
            
            
            Severity: Minor
            Found in kiwi/data/datasets/wmt_qe_dataset.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

            Function build has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
            Open

                def build(
                    config: Config, directory=None, train=False, valid=False, test=False, split=0
                ):
                    """Build training, validation, and test datasets.
            
            
            Severity: Minor
            Found in kiwi/data/datasets/parallel_dataset.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 tlm_system.py has 355 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            #  OpenKiwi: Open-Source Machine Translation Quality Estimation
            #  Copyright (C) 2020 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/systems/tlm_system.py - About 4 hrs to fix

              File xlmroberta.py has 347 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              #  OpenKiwi: Open-Source Machine Translation Quality Estimation
              #  Copyright (C) 2020 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/systems/encoders/xlmroberta.py - About 4 hrs to fix

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

                #  OpenKiwi: Open-Source Machine Translation Quality Estimation
                #  Copyright (C) 2020 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

                  Function suggest_train_config has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def suggest_train_config(self, trial) -> Tuple[train.Configuration, dict]:
                          """Use the trial to suggest values to initialize a training configuration.
                  
                          Arguments:
                              trial: An Optuna trial to make hyperparameter suggestions.
                  Severity: Minor
                  Found in kiwi/lib/search.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

                  Function normalize_prediction_files has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def normalize_prediction_files(
                      predicted_files_config: List[OutputConfig], predicted_dir_config: List[Path],
                  ):
                      prediction_files = defaultdict(list)
                      if predicted_files_config:
                  Severity: Minor
                  Found in kiwi/lib/evaluate.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 predictor.py has 331 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  #  OpenKiwi: Open-Source Machine Translation Quality Estimation
                  #  Copyright (C) 2020 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/systems/encoders/predictor.py - About 3 hrs to fix

                    File bert.py has 316 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    #  OpenKiwi: Open-Source Machine Translation Quality Estimation
                    #  Copyright (C) 2020 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/systems/encoders/bert.py - About 3 hrs to fix

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

                          def __init__(self, inputs_dims, vocabs: Dict[str, Vocabulary], config: Config):
                              super().__init__(config=config)
                      
                              self.inputs_dims = inputs_dims
                              self.config = config
                      Severity: Minor
                      Found in kiwi/systems/outputs/quality_estimation.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 from_config has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def from_config(
                          config: OptimizerConfig,
                          parameters: Iterator[Parameter],
                          model_size: int = None,
                          training_data_size: int = None,
                      Severity: Minor
                      Found in kiwi/training/optimizers.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 14 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def __init__(
                      Severity: Major
                      Found in kiwi/data/vocabulary.py - About 1 hr to fix

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

                            def __init__(
                        Severity: Major
                        Found in kiwi/data/encoders/field_encoders.py - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language