LucaCappelletti94/italian_csv_type_prediction

View on GitHub

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

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

class NameSurnameType(SetTypeColumnPredictor):
    def __init__(self):
        """Create new Predictor based on a single type."""
        super().__init__(
            SimpleNameSurnameType(),
Severity: Minor
Found in italian_csv_type_prediction/column_types/single_type_column.py and 1 other location - About 55 mins to fix
italian_csv_type_prediction/column_types/single_type_column.py on lines 54..61

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

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

class SurnameNameType(SetTypeColumnPredictor):
    def __init__(self):
        """Create new Predictor based on a single type."""
        super().__init__(
            SimpleSurnameNameType(),
Severity: Minor
Found in italian_csv_type_prediction/column_types/single_type_column.py and 1 other location - About 55 mins to fix
italian_csv_type_prediction/column_types/single_type_column.py on lines 66..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 37.

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

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

    class ItalianFiscalCodeType(SetTypeColumnPredictor):
        def __init__(self):
            """Create new Predictor based on a single type."""
            super().__init__(
                SimpleItalianFiscalCodeType(),
    Severity: Minor
    Found in italian_csv_type_prediction/column_types/single_type_column.py and 1 other location - About 45 mins to fix
    italian_csv_type_prediction/column_types/single_type_column.py on lines 170..175

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

    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

    class ItalianVATType(SetTypeColumnPredictor):
        def __init__(self):
            """Create new Predictor based on a single type."""
            super().__init__(
                SimpleItalianVATType(),
    Severity: Minor
    Found in italian_csv_type_prediction/column_types/single_type_column.py and 1 other location - About 45 mins to fix
    italian_csv_type_prediction/column_types/single_type_column.py on lines 97..102

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

    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

    class NameType(SetTypeColumnPredictor):
        def __init__(self):
            """Create new Predictor based on a single type."""
            super().__init__(
                SimpleNameType(),
    Severity: Minor
    Found in italian_csv_type_prediction/column_types/single_type_column.py and 1 other location - About 40 mins to fix
    italian_csv_type_prediction/column_types/single_type_column.py on lines 233..239

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

    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

    class SurnameType(SetTypeColumnPredictor):
        def __init__(self):
            """Create new Predictor based on a single type."""
            super().__init__(
                SimpleSurnameType(),
    Severity: Minor
    Found in italian_csv_type_prediction/column_types/single_type_column.py and 1 other location - About 40 mins to fix
    italian_csv_type_prediction/column_types/single_type_column.py on lines 186..192

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

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

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

      class DocumentType(SetTypeColumnPredictor):
          def __init__(self):
              """Create new Predictor based on a single type."""
              super().__init__(SimpleDocumentType(), generalizations=SimpleStringType())
      Severity: Minor
      Found in italian_csv_type_prediction/column_types/single_type_column.py and 1 other location - About 30 mins to fix
      italian_csv_type_prediction/column_types/single_type_column.py on lines 39..44

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

      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

      class AddressType(SetTypeColumnPredictor):
          def __init__(self):
              """Create new Predictor based on a single type."""
              super().__init__(
                  SimpleAddressType(),
      Severity: Minor
      Found in italian_csv_type_prediction/column_types/single_type_column.py and 1 other location - About 30 mins to fix
      italian_csv_type_prediction/column_types/single_type_column.py on lines 146..149

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

      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

      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
            Severity
            Category
            Status
            Source
            Language