IlyaGusev/rulm

View on GitHub

Showing 204 of 260 total issues

Function anthropic_completion has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def anthropic_completion(
Severity: Minor
Found in self_instruct/src/anthropic_wrapper.py - About 45 mins to fix

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

    def main(input_path, output_path):
        with open(input_path, "r") as r, open(output_path, "w") as w:
            def flush(text_id, fragments):
                text = " ".join(fragments)
                text = preprocess_text(text, text_id)
    Severity: Minor
    Found in data_processing/create_librusec.py - About 45 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 get_parus has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_parus(split):
        dataset = load_dataset(HF_DATASET, "parus", split=split)
        for row in dataset:
            is_cause = row["question"] == "cause"
            c1 = row["choice1"].rstrip(".").lower()
    Severity: Minor
    Found in self_instruct/src/data_processing/convert_rsg.py - About 45 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

    Avoid deeply nested control flow statements.
    Open

                    if current_agent and current_message:
                        if current_agent != "bot":
                            is_bad_record = True
                            break
                        messages.append({
    Severity: Major
    Found in self_instruct/src/data_processing/postprocess_chat.py - About 45 mins to fix

      Function interact has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def interact(
      Severity: Minor
      Found in self_instruct/src/interact_llamacpp.py - About 45 mins to fix

        Function predict has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def predict(k_shots: pd.DataFrame, test_data: pd.DataFrame, task_name: str, predict_func, batch_size):
            if task_name in ['ru_worldtree', 'ru_openbook']:
                k_shots_pairs = [(OPENBOOK_PROMPT, "B")]
                for row in k_shots.to_dict(orient="records"):
                    question = row["question"]
        Severity: Minor
        Found in self_instruct/src/benchmarks/eval_zs_tape.py - About 45 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 predict_danetqa has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def predict_danetqa(
            split,
            predict_func,
            output_path,
            batch_size: int = 4,
        Severity: Minor
        Found in self_instruct/src/benchmarks/eval_zs_rsg.py - About 45 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 get_russe has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_russe(split, sample_rate: float = 0.1):
            dataset = load_dataset(HF_DATASET, "russe", split=split)
            for row in dataset:
                if split != "test" and random.random() > sample_rate:
                    continue
        Severity: Minor
        Found in self_instruct/src/data_processing/convert_rsg.py - About 45 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

        Avoid deeply nested control flow statements.
        Open

                        if current_agent and current_message:
                            if current_agent != "user":
                                is_bad_record = True
                                break
                            messages.append({
        Severity: Major
        Found in self_instruct/src/data_processing/postprocess_chat.py - About 45 mins to fix

          Function generate has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def generate(
          Severity: Minor
          Found in self_instruct/src/util/generate.py - About 45 mins to fix

            Function predict_lidirus has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def predict_lidirus(
            Severity: Minor
            Found in self_instruct/src/benchmarks/eval_zs_rsg.py - About 45 mins to fix

              Function get_pool has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_pool(pool_id, toloka_client):
                  records = []
                  for assignment in toloka_client.get_assignments(pool_id=pool_id):
                      solutions = assignment.solutions
                      if not solutions:
              Severity: Minor
              Found in self_instruct/crowd/aggregate.py - About 45 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 main has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def main(
                  input_path,
                  output_path,
                  template_path,
                  model_name="gpt-3.5-turbo",
              Severity: Minor
              Found in self_instruct/src/sbs/eval_gpt.py - About 45 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

              Avoid deeply nested control flow statements.
              Open

                                  if host in record.url:
                                      is_bad_host = True
                              if is_bad_host:
              Severity: Major
              Found in data_processing/create_ru_news.py - About 45 mins to fix

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

                    def __init__(self, posts_path, users_path, comments_path, output_path, min_score=-1000, max_responses=1000):
                Severity: Minor
                Found in data_processing/create_stackoverflow.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      with connection.cursor() as comments_cursor:
                                          comments_cursor.execute("SELECT * FROM pikabu_comments WHERE story_id = {}".format(record["id"]))
                                          for row in comments_cursor:
                                              header = [desc.name for desc in comments_cursor.description]
                                              comment = dict(zip(header, row))
                  Severity: Major
                  Found in data_processing/convert_pikabu.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if clean_section:
                                            clean_sections.append(clean_section)
                                    record["sections"] = clean_sections
                    Severity: Major
                    Found in data_processing/parse_zip_fb2.py - About 45 mins to fix

                      Function main has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      def main(
                      Severity: Minor
                      Found in data_processing/create_ru_news.py - About 45 mins to fix

                        Function split has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        def split(
                        Severity: Minor
                        Found in data_processing/split.py - About 45 mins to fix

                          Function train_tokenizer has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def train_tokenizer(
                              dataset_path,
                              train_path,
                              output_dir,
                              sample_rate,
                          Severity: Minor
                          Found in rulm/train_tokenizer.py - About 45 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

                          Severity
                          Category
                          Status
                          Source
                          Language