IlyaGusev/rulm

View on GitHub

Showing 260 of 260 total issues

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

print(Counter(y_pred)[1] / (Counter(y_pred)[-1] + Counter(y_pred)[1]))
Severity: Major
Found in self_instruct/src/bot/calc_sbs_agreement.py and 1 other location - About 1 hr to fix
self_instruct/src/bot/calc_sbs_agreement.py on lines 38..38

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

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

print(Counter(y_true)[1] / (Counter(y_true)[-1] + Counter(y_pred)[1]))
Severity: Major
Found in self_instruct/src/bot/calc_sbs_agreement.py and 1 other location - About 1 hr to fix
self_instruct/src/bot/calc_sbs_agreement.py on lines 37..37

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

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

def main(input_path, output_path):
    processor = TextProcessor(
        normalization="NFKC",
        min_chars=0,
        min_text_part=0,
Severity: Minor
Found in data_processing/clean_ficbook.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

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

        if "val" in data_files:
            gens.append(datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"files": data_files["val"]}))
Severity: Major
Found in rulm/jsonl_loader.py and 2 other locations - About 1 hr to fix
rulm/jsonl_loader.py on lines 47..48
rulm/jsonl_loader.py on lines 49..50

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

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 train has 12 arguments (exceeds 4 allowed). Consider refactoring.
Open

def train(
Severity: Major
Found in rulm/train.py - About 1 hr to fix

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

            if "train" in data_files:
                gens.append(datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"files": data_files["train"]}))
    Severity: Major
    Found in rulm/jsonl_loader.py and 2 other locations - About 1 hr to fix
    rulm/jsonl_loader.py on lines 49..50
    rulm/jsonl_loader.py on lines 51..52

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

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

            if "test" in data_files:
                gens.append(datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"files": data_files["test"]}))
    Severity: Major
    Found in rulm/jsonl_loader.py and 2 other locations - About 1 hr to fix
    rulm/jsonl_loader.py on lines 47..48
    rulm/jsonl_loader.py on lines 51..52

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

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

    def undup_by_ngrams(records, n: int = 8):
        existing_ngrams = dict()
        new_records = []
        records.sort(key=lambda x: x["opus_score"])
        for r in records:
    Severity: Minor
    Found in self_instruct/src/data_processing/to_parquet.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 compose_sft_dataset has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def compose_sft_dataset(config_path: str, train_path: str, val_path: str):
        with open(config_path) as r:
            config = json.load(r)
    
        records = []
    Severity: Minor
    Found in self_instruct/src/data_processing/compose_sft_dataset.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 generate_answers has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def generate_answers(
        model_name: str,
        input_path: str,
        output_path: str,
        batch_size: int = 1
    Severity: Minor
    Found in self_instruct/src/infer_fred.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 dump_librusec has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def dump_librusec(archive, sample_rate=0.15):
        max_sentences_count = 100
        text_processor = TextProcessor()
        librusec = load_dataset("IlyaGusev/librusec", split="train", streaming=True)
        for row in tqdm(librusec):
    Severity: Minor
    Found in data_processing/save_hf.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 parse_post has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_post(post_id):
        api_url = "https://habr.com/kek/v2/articles/{}".format(post_id)
        post_url = "https://habr.com/ru/post/{}/".format(post_id)
    
        try:
    Severity: Minor
    Found in data_processing/create_habr.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 process_batch has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def process_batch(
    Severity: Major
    Found in self_instruct/src/data_processing/improve_instructions.py - About 1 hr to fix

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

          def __init__(
      Severity: Major
      Found in self_instruct/src/dataset.py - About 1 hr to fix

        Function generate_instructions has 10 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def generate_instructions(
        Severity: Major
        Found in self_instruct/src/data_processing/generate_instructions.py - About 1 hr to fix

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

          def main(
              chars_path,
              output_path,
              template_path,
              model_name="gpt-4",
          Severity: Minor
          Found in self_instruct/src/data_processing/generate_char_image_prompts.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 evolve_batch has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          def evolve_batch(
              original_tasks,
              model_name,
              decoding_args,
              depth_template_path: str = None,
          Severity: Minor
          Found in self_instruct/src/data_processing/improve_instructions.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 annotate_meta_claude has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          def annotate_meta_claude(
              input_path: str,
              output_path: str,
              model_name: str = "claude-3-sonnet-20240229"
          ):
          Severity: Minor
          Found in self_instruct/src/data_processing/annotate_meta_claude.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 generate_chars has 10 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def generate_chars(
          Severity: Major
          Found in self_instruct/src/data_processing/generate_chars.py - About 1 hr to fix

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

            def main(
                input_path,
                seed,
                token,
                existing_markup_path,
            Severity: Minor
            Found in self_instruct/crowd/upload.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