How to use the wily.operators.Metric function in wily

To help you get started, we’ve selected a few wily examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tonybaloney / wily / src / wily / operators / raw.py View on Github external
class RawMetricsOperator(BaseOperator):
    """Raw Metrics Operator."""

    name = "raw"
    defaults = {
        "exclude": None,
        "ignore": None,
        "summary": False,
        "include_ipynb": True,
        "ipynb_cells": True,
    }
    metrics = (
        Metric("loc", "Lines of Code", int, MetricType.Informational, sum),
        Metric("lloc", "L Lines of Code", int, MetricType.AimLow, sum),
        Metric("sloc", "S Lines of Code", int, MetricType.AimLow, sum),
        Metric("comments", "Multi-line comments", int, MetricType.AimHigh, sum),
        Metric("multi", "Multi lines", int, MetricType.Informational, sum),
        Metric("blank", "blank lines", int, MetricType.Informational, sum),
        Metric(
            "single_comments",
            "Single comment lines",
            int,
            MetricType.Informational,
            sum,
        ),
    )
    default_metric_index = 0  # LOC

    def __init__(self, config, targets):
        """
        Instantiate a new raw operator.
github tonybaloney / wily / src / wily / operators / raw.py View on Github external
name = "raw"
    defaults = {
        "exclude": None,
        "ignore": None,
        "summary": False,
        "include_ipynb": True,
        "ipynb_cells": True,
    }
    metrics = (
        Metric("loc", "Lines of Code", int, MetricType.Informational, sum),
        Metric("lloc", "L Lines of Code", int, MetricType.AimLow, sum),
        Metric("sloc", "S Lines of Code", int, MetricType.AimLow, sum),
        Metric("comments", "Multi-line comments", int, MetricType.AimHigh, sum),
        Metric("multi", "Multi lines", int, MetricType.Informational, sum),
        Metric("blank", "blank lines", int, MetricType.Informational, sum),
        Metric(
            "single_comments",
            "Single comment lines",
            int,
            MetricType.Informational,
            sum,
        ),
    )
    default_metric_index = 0  # LOC

    def __init__(self, config, targets):
        """
        Instantiate a new raw operator.

        :param config: The wily configuration.
        :type  config: :class:`WilyConfig`
github tonybaloney / wily / src / wily / operators / halstead.py View on Github external
defaults = {
        "exclude": None,
        "ignore": None,
        "min": "A",
        "max": "C",
        "multi": True,
        "show": False,
        "sort": False,
        "by_function": True,
        "include_ipynb": True,
        "ipynb_cells": True,
    }

    metrics = (
        Metric("h1", "Unique Operands", int, MetricType.AimLow, sum),
        Metric("h2", "Unique Operators", int, MetricType.AimLow, sum),
        Metric("N1", "Number of Operands", int, MetricType.AimLow, sum),
        Metric("N2", "Number of Operators", int, MetricType.AimLow, sum),
        Metric(
            "vocabulary", "Unique vocabulary (h1 + h2)", int, MetricType.AimLow, sum
        ),
        Metric("length", "Length of application", int, MetricType.AimLow, sum),
        Metric("volume", "Code volume", float, MetricType.AimLow, sum),
        Metric("difficulty", "Difficulty", float, MetricType.AimLow, sum),
        Metric("effort", "Effort", float, MetricType.AimLow, sum),
    )

    default_metric_index = 0  # MI

    def __init__(self, config, targets):
        """
        Instantiate a new HC operator.
github tonybaloney / wily / src / wily / operators / raw.py View on Github external
class RawMetricsOperator(BaseOperator):
    """Raw Metrics Operator."""

    name = "raw"
    defaults = {
        "exclude": None,
        "ignore": None,
        "summary": False,
        "include_ipynb": True,
        "ipynb_cells": True,
    }
    metrics = (
        Metric("loc", "Lines of Code", int, MetricType.Informational, sum),
        Metric("lloc", "L Lines of Code", int, MetricType.AimLow, sum),
        Metric("sloc", "S Lines of Code", int, MetricType.AimLow, sum),
        Metric("comments", "Multi-line comments", int, MetricType.AimHigh, sum),
        Metric("multi", "Multi lines", int, MetricType.Informational, sum),
        Metric("blank", "blank lines", int, MetricType.Informational, sum),
        Metric(
            "single_comments",
            "Single comment lines",
            int,
            MetricType.Informational,
            sum,
        ),
    )
    default_metric_index = 0  # LOC

    def __init__(self, config, targets):
        """
github tonybaloney / wily / src / wily / operators / halstead.py View on Github external
"show": False,
        "sort": False,
        "by_function": True,
        "include_ipynb": True,
        "ipynb_cells": True,
    }

    metrics = (
        Metric("h1", "Unique Operands", int, MetricType.AimLow, sum),
        Metric("h2", "Unique Operators", int, MetricType.AimLow, sum),
        Metric("N1", "Number of Operands", int, MetricType.AimLow, sum),
        Metric("N2", "Number of Operators", int, MetricType.AimLow, sum),
        Metric(
            "vocabulary", "Unique vocabulary (h1 + h2)", int, MetricType.AimLow, sum
        ),
        Metric("length", "Length of application", int, MetricType.AimLow, sum),
        Metric("volume", "Code volume", float, MetricType.AimLow, sum),
        Metric("difficulty", "Difficulty", float, MetricType.AimLow, sum),
        Metric("effort", "Effort", float, MetricType.AimLow, sum),
    )

    default_metric_index = 0  # MI

    def __init__(self, config, targets):
        """
        Instantiate a new HC operator.

        :param config: The wily configuration.
        :type  config: :class:`WilyConfig`
        """
        # TODO : Import config from wily.cfg
        logger.debug(f"Using {targets} with {self.defaults} for HC metrics")
github tonybaloney / wily / src / wily / operators / halstead.py View on Github external
"exclude": None,
        "ignore": None,
        "min": "A",
        "max": "C",
        "multi": True,
        "show": False,
        "sort": False,
        "by_function": True,
        "include_ipynb": True,
        "ipynb_cells": True,
    }

    metrics = (
        Metric("h1", "Unique Operands", int, MetricType.AimLow, sum),
        Metric("h2", "Unique Operators", int, MetricType.AimLow, sum),
        Metric("N1", "Number of Operands", int, MetricType.AimLow, sum),
        Metric("N2", "Number of Operators", int, MetricType.AimLow, sum),
        Metric(
            "vocabulary", "Unique vocabulary (h1 + h2)", int, MetricType.AimLow, sum
        ),
        Metric("length", "Length of application", int, MetricType.AimLow, sum),
        Metric("volume", "Code volume", float, MetricType.AimLow, sum),
        Metric("difficulty", "Difficulty", float, MetricType.AimLow, sum),
        Metric("effort", "Effort", float, MetricType.AimLow, sum),
    )

    default_metric_index = 0  # MI

    def __init__(self, config, targets):
        """
        Instantiate a new HC operator.
github tonybaloney / wily / src / wily / operators / cyclomatic.py View on Github external
name = "cyclomatic"
    defaults = {
        "exclude": None,
        "ignore": None,
        "min": "A",
        "max": "F",
        "no_assert": True,
        "show_closures": False,
        "order": radon.complexity.SCORE,
        "include_ipynb": True,
        "ipynb_cells": True,
    }

    metrics = (
        Metric(
            "complexity",
            "Cyclomatic Complexity",
            float,
            MetricType.AimLow,
            statistics.mean,
        ),
    )

    default_metric_index = 0  # MI

    def __init__(self, config, targets):
        """
        Instantiate a new Cyclomatic Complexity operator.

        :param config: The wily configuration.
        :type  config: :class:`WilyConfig`
github tonybaloney / wily / src / wily / operators / raw.py View on Github external
class RawMetricsOperator(BaseOperator):
    """Raw Metrics Operator."""

    name = "raw"
    defaults = {
        "exclude": None,
        "ignore": None,
        "summary": False,
        "include_ipynb": True,
        "ipynb_cells": True,
    }
    metrics = (
        Metric("loc", "Lines of Code", int, MetricType.Informational, sum),
        Metric("lloc", "L Lines of Code", int, MetricType.AimLow, sum),
        Metric("sloc", "S Lines of Code", int, MetricType.AimLow, sum),
        Metric("comments", "Multi-line comments", int, MetricType.AimHigh, sum),
        Metric("multi", "Multi lines", int, MetricType.Informational, sum),
        Metric("blank", "blank lines", int, MetricType.Informational, sum),
        Metric(
            "single_comments",
            "Single comment lines",
            int,
            MetricType.Informational,
            sum,
        ),
    )
    default_metric_index = 0  # LOC

    def __init__(self, config, targets):
        """
        Instantiate a new raw operator.