File preprocess.py
has 439 lines of code (exceeds 250 allowed). Consider refactoring. Open
# Copyright 2024 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Function _make_features
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def _make_features(self, stride_index: int, paragraph_texts: List[Text],
paragraphs: List[Paragraph],
question_answer_evidence: QuestionAnswerEvidence,
ids: List[int],
paragraph_offset: int) -> Tuple[int, Features]:
- Read upRead up
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 _handle_exceptional_examples
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def _handle_exceptional_examples(
features: Features,
processor: spm.SentencePieceProcessor) -> List[AnswerSpan]:
"""Special cases in data."""
if features.id == 'qw_6687--Viola.txt':
- Read upRead up
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
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def process(
self,
element: Tuple[Text, List[Features]],
answer_sets: Dict[Text, Set[Text]],
) -> Generator[Tuple[Features, List[AnswerSpan]], None, None]:
- Read upRead up
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 make_pipeline
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def make_pipeline(root: beam.Pipeline, question_answers: List[QuestionAnswer],
Function read_question_answers
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def read_question_answers(json_path: Text) -> List[QuestionAnswer]:
"""Read question answers."""
with gfile.GFile(json_path) as f:
data = json.load(f)['Data']
question_answers = []
- Read upRead up
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 realign_answer_span
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def realign_answer_span(features: Features, answer_set: Optional[Set[Text]],
processor: spm.SentencePieceProcessor,
span: AnswerSpan) -> Optional[AnswerSpan]:
"""Align answer span to text with given tokens."""
i = bisect.bisect_left(features.token_offsets, span.begin)
- Read upRead up
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 _make_features
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _make_features(self, stride_index: int, paragraph_texts: List[Text],
Function make_paragraph
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def make_paragraph(
Avoid too many return
statements within this function. Open
return spans
Avoid too many return
statements within this function. Open
return []