whylabs/whylogs-python

View on GitHub

Showing 931 of 943 total issues

DatasetProfile has 35 functions (exceeds 20 allowed). Consider refactoring.
Open

class DatasetProfile:
    """
    Statistics tracking for a dataset.

    A dataset refers to a collection of columns.
Severity: Minor
Found in src/whylogs/core/datasetprofile.py - About 4 hrs to fix

    Function estimate_segments has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    def estimate_segments(
        df: pyspark.sql.dataframe.DataFrame,
        target_field: str = None,
        max_segments: int = 30,
        include_columns: List[str] = [],
    Severity: Minor
    Found in java/spark/python/whyspark/preprocessing/autosegmentation.py - About 3 hrs 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

    Logger has 31 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Logger:
        """
        Class for logging whylogs statistics.
    
        :param session_id: The session ID value. Should be set by the Session boject
    Severity: Minor
    Found in src/whylogs/app/logger.py - About 3 hrs to fix

      Function _estimate_segments has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

      def _estimate_segments(df: pd.DataFrame, target_field: str = None, max_segments: int = 30) -> Optional[Union[List[Dict], List[str]]]:
          """
          Estimates the most important features and values on which to segment
          data profiling using entropy-based methods.
      
      
      Severity: Minor
      Found in src/whylogs/features/autosegmentation.py - About 3 hrs 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

      DatasetProfile has 26 methods (exceeds 20 allowed). Consider refactoring.
      Open

      @AllArgsConstructor
      public class DatasetProfile implements Serializable {
        // generated by IntelliJ
        private static final long serialVersionUID = -9221998596693275458L;
        public static final String TAG_PREFIX = "whylogs.tag.";
      Severity: Minor
      Found in java/core/src/main/java/com/whylogs/core/DatasetProfile.java - About 3 hrs to fix

        Method calculateFormat has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          private Instant calculateFormat(String firstInput) {
            val parsed = dateTimeFormatter.parse(firstInput);
            val hasYear = parsed.isSupported(ChronoField.YEAR);
            val hasMonth = parsed.isSupported(ChronoField.MONTH_OF_YEAR);
            val hasDayOfMonth = parsed.isSupported(ChronoField.DAY_OF_MONTH);

        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

        FrequentItemsSketch has 22 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class FrequentItemsSketch:
            """
            A class to implement frequent item counting for mixed data types.
        
            Wraps `datasketches.frequent_strings_sketch` by encoding numbers as
        Severity: Minor
        Found in src/whylogs/util/dsketch.py - About 2 hrs to fix

          Function flush has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              def flush(self, rotation_suffix: str = None):
                  """
                  Synchronously perform all remaining write tasks
                  """
                  if not self._active:
          Severity: Minor
          Found in src/whylogs/app/logger.py - About 2 hrs 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

          Method run has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            @SneakyThrows
            @Override
            public void run() {
              validateFiles();
          
          
          Severity: Minor
          Found in java/cli/src/main/java/com/whylogs/cli/Profiler.java - About 2 hrs 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 log_segment_datum has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def log_segment_datum(self, feature_name, value, character_list: str = None, token_method: Optional[Callable] = None):
                  segment = [{"key": feature_name, "value": value}]
                  segment_profile = self.get_segment(segment)
                  if self.segment_type == "keys":
                      if feature_name in self.segments:
          Severity: Minor
          Found in src/whylogs/app/logger.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 load_config has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          def load_config(path_to_config: str = None):
              """
              Load logging configuration, from disk and from the environment.
          
              Config is loaded by attempting to load files in the following order.  The
          Severity: Minor
          Found in src/whylogs/app/config.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

          Method merge has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

            public StringTracker merge(StringTracker other) {
              ItemsSketch<String> itemsCopy = null;
              if (other == null) {
                return this;
              }

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

              def _rotate_time(self):
                  """
                  rotate with time add a suffix
                  """
          
          
          Severity: Minor
          Found in src/whylogs/app/logger.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 init has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          def init(project_dir):
              """
              Initialize and configure a new whylogs project.
          
              This guided input walks the user through setting up a new project and also
          Severity: Minor
          Found in src/whylogs/cli/demo_cli.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

          Method fromUpdateDoublesSketch has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            private static HistogramSummary fromUpdateDoublesSketch(
                final KllFloatsSketch sketch, int nBins, @Nullable float[] splitPoints) {
              nBins = splitPoints != null ? splitPoints.length + 1 : (nBins > 0 ? nBins : 30);
              if (nBins < 2) {
                throw new IllegalArgumentException("at least 2 bins expected");
          Severity: Minor
          Found in java/core/src/main/java/com/whylogs/core/SummaryConverters.java - 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 _init_dataset has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def _init_dataset(
                  self,
              ) -> List[Tuple[str, int]]:
          
                  self.items = []
          Severity: Minor
          Found in src/whylogs/io/local_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 update has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def update(self, value: str, character_list: str = None) -> None:
                  """update
          
                  Parameters
                  ----------
          Severity: Minor
          Found in src/whylogs/core/statistics/stringtracker.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 merge has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def merge(self, other: "CharPosTracker") -> "CharPosTracker":
                  """
                  Merges two Char Pos Frequency Maps
          
                  Args:
          Severity: Minor
          Found in src/whylogs/core/statistics/stringtracker.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 __init__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(
                  self,
                  output_path: str,
                  formats: List[str],
                  path_template: typing.Optional[str] = None,
          Severity: Minor
          Found in src/whylogs/app/writers.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

            public void add(LongTracker other) {
              if (other == null) {
                return;
              }
          
          
          java/core/src/main/java/com/whylogs/core/statistics/datatypes/DoubleTracker.java on lines 53..66

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

          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

          Severity
          Category
          Status
          Source
          Language