Unbabel/OpenKiwi

View on GitHub

Showing 236 of 264 total issues

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

    def __init__(
Severity: Minor
Found in kiwi/data/vectors.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 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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

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

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

          def run(ModelClass, output_dir, pipeline_options, model_options, splits):
          Severity: Minor
          Found in kiwi/lib/jackknife.py - About 35 mins to fix

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

            def filter_len(
            Severity: Minor
            Found in kiwi/data/utils.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 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 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

                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

                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

                    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/quetch.py and 1 other location - About 35 mins to fix
                kiwi/data/fieldsets/linear.py on lines 62..66

                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

                                        'Dev scores: %s'
                                        % ' '.join(
                                            ["%.5g" % (100 * score) for score in dev_scores]
                Severity: Minor
                Found in kiwi/models/linear/linear_trainer.py and 1 other location - About 35 mins to fix
                kiwi/models/linear/linear_trainer.py 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 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 i == 0:
                                previous_word = '<s>'
                                # previous_tag = '<s>'
                            else:
                                previous_word = target_words[i - 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 201..205

                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 not nearly_eq_tol(
                                        gold_output[r], predicted_output[r], 1e-6
                                    ):
                                        num_mistakes += 1
                Severity: Minor
                Found in kiwi/models/linear/linear_trainer.py and 1 other location - About 35 mins to fix
                kiwi/models/linear/structured_classifier.py on lines 112..114

                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

                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

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

                            for i in range(num_parts):
                                if not nearly_eq_tol(gold_output[i], predicted_output[i], 1e-6):
                                    num_mistakes += 1
                Severity: Minor
                Found in kiwi/models/linear/structured_classifier.py and 1 other location - About 35 mins to fix
                kiwi/models/linear/linear_trainer.py on lines 138..141

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

                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