LucaCappelletti94/italian_csv_type_prediction

View on GitHub

Showing 15 of 23 total issues

Function generate_simple_dataframe has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def generate_simple_dataframe(
        self,
        nan_percentage: float = 0.05,
        error_percentage: float = 0.01,
        min_rows: int = 5,

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 15 (exceeds 5 allowed). Consider refactoring.
Open

def main(model=None, new_model_name="animal", output_dir=None, n_iter=30):
    """Set up the pipeline and entity recognizer, and train the new entity."""
    random.seed(0)
    if model is not None:
        nlp = spacy.load(model)  # load existing spaCy model
Severity: Minor
Found in example.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 extract has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def extract(self, candidate: str, candidate_type: str, **kwargs) -> Dict:
        from postal.parser import parse_address

        lower = candidate.lower()
        parsed = parse_address(
Severity: Minor
Found in italian_csv_type_prediction/mixed_types/address_extractor.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 validate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def validate(self, values: List, fiscal_codes: List = None, italian_vat_codes: List = None, **kwargs: Dict) -> List[bool]:
        """Return list of booleans representing if each value has been identified.

        Parameters
        -----------------------------------
Severity: Minor
Found in italian_csv_type_prediction/column_types/set_type_column.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 convert has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def convert(self, candidate, **kwargs):
        for separator in self._separators:
            if candidate.count(separator) == 1:
                full_names = (candidate.split(separator),)
            elif not any(sep in candidate for sep in self._separators[:-1]) and candidate.count(separator)>0:
Severity: Minor
Found in italian_csv_type_prediction/simple_types/full_name_type.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 _handle_value_extraction has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def _handle_value_extraction(self, candidate: str, candidate_type: str, **kwargs: Dict) -> Dict:
        """Return extraction of given candidate.

        Parameters
        ---------------------
Severity: Minor
Found in italian_csv_type_prediction/mixed_types/placeholder_extractor.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Minor
Found in italian_csv_type_prediction/column_types/set_type_column.py - About 45 mins to fix

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

        def generate_simple_dataframe(

      Function validate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate(self, candidate, **kwargs) -> bool:
              """Return boolean representing if given candidate matches regex for float values."""
              if str(candidate) == "0":
                  return True
              if isinstance(candidate, bool):
      Severity: Minor
      Found in italian_csv_type_prediction/simple_types/float_type.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

      Avoid too many return statements within this function.
      Open

                  return False
      Severity: Major
      Found in italian_csv_type_prediction/simple_types/float_type.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return False
        Severity: Major
        Found in italian_csv_type_prediction/simple_types/float_type.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return np.isfinite(candidate)
          Severity: Major
          Found in italian_csv_type_prediction/simple_types/float_type.py - About 30 mins to fix

            Function get_column has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_column(self, df: pd.DataFrame, validator: ColumnTypePredictor) -> List:
                    for column in df.columns:
                        predictions = validator.validate(df[column])
                        if any(predictions):
                            return [
            Severity: Minor
            Found in italian_csv_type_prediction/embedding/dataframe_embedding.py - About 25 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 reverse_translate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def reverse_translate(self, value_type: Union[str, List, Tuple]) -> str:
                    """Return value type translated back to english from given language.
            
                    Parameters
                    ----------------------
            Severity: Minor
            Found in italian_csv_type_prediction/utils/translator.py - About 25 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 translate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def translate(self, value_type: Union[List, Tuple]) -> str:
                    """Return value type translated to given language.
            
                    Parameters
                    ----------------------
            Severity: Minor
            Found in italian_csv_type_prediction/utils/translator.py - About 25 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