Beispiel #1
0
def test_cc(mocker, log_mock):
    harv_mock = mocker.patch('radon.cli.CCHarvester')
    harv_mock.return_value = mocker.sentinel.harvester

    cli.cc(['-'], json=True)

    harv_mock.assert_called_once_with(['-'],
                                      cli.Config(min='A',
                                                 max='F',
                                                 exclude=None,
                                                 ignore=None,
                                                 show_complexity=False,
                                                 average=False,
                                                 order=getattr(
                                                     cc_mod, 'SCORE'),
                                                 no_assert=False,
                                                 total_average=False,
                                                 show_closures=False,
                                                 include_ipynb=False,
                                                 ipynb_cells=False))
    log_mock.assert_called_once_with(mocker.sentinel.harvester,
                                     codeclimate=False,
                                     json=True,
                                     stream=sys.stdout,
                                     xml=False)
Beispiel #2
0
def _run_complexity_analysis(on_ci):
    """Generates cyclomatic complexity reports for the package

    :param bool on_ci: Indicates whether an automated tool is running this operation. Output will be customized for
                    machine readability
    """
    modlog.debug("Running complexity analysis")

    # generate cyclomatic complexities for source files in XML format for integration with external tools
    pyjen_path = os.path.join(os.getcwd(), "pyjen")
    from radon.cli import cc

    # TODO: output in XML format when running on CI
    standard_output = StringIO()
    with redirect_stdout(standard_output):
        modlog.debug("Calling radon.cc")
        cc(paths=[pyjen_path], show_complexity=True, show_closures=True, total_average=True, xml=on_ci)

    modlog.debug("Writing report to disk")
    cc_report = os.path.join(log_folder, "radon_complexity.xml")
    with open(cc_report, "w") as fh:
        fh.write(standard_output.getvalue())
    standard_output.close()

    modlog.info("Cyclomatic complexity analysis complete. See " + os.path.relpath(cc_report))
Beispiel #3
0
def _run_complexity_analysis(on_ci):
    """Generates cyclomatic complexity reports for the package

    :param bool on_ci: Indicates whether an automated tool is running this operation. Output will be customized for
                    machine readability
    """
    modlog.debug("Running complexity analysis")

    # generate cyclomatic complexities for source files in XML format for integration with external tools
    pyjen_path = os.path.join(os.getcwd(), "pyjen")
    from radon.cli import cc

    # TODO: output in XML format when running on CI
    standard_output = StringIO()
    with redirect_stdout(standard_output):
        modlog.debug("Calling radon.cc")
        cc(paths=[pyjen_path],
           show_complexity=True,
           show_closures=True,
           total_average=True,
           xml=on_ci)

    modlog.debug("Writing report to disk")
    cc_report = os.path.join(log_folder, "radon_complexity.xml")
    with open(cc_report, "w") as fh:
        fh.write(standard_output.getvalue())
    standard_output.close()

    modlog.info("Cyclomatic complexity analysis complete. See " +
                os.path.relpath(cc_report))
Beispiel #4
0
    def test_cc(self, harv_mock, log_mock):
        harv_mock.return_value = mock.sentinel.harvester

        cli.cc(['-'], json=True)

        harv_mock.assert_called_once_with(['-'], cli.Config(
            min='A', max='F', exclude=None, ignore=None, show_complexity=False,
            average=False, order=getattr(cc_mod, 'SCORE'), no_assert=False,
            total_average=False, show_closures=False))
        log_mock.assert_called_once_with(mock.sentinel.harvester, json=True,
                                         xml=False)
Beispiel #5
0
    def test_cc(self, harv_mock, log_mock):
        harv_mock.return_value = mock.sentinel.harvester

        cli.cc(['-'], json=True)

        harv_mock.assert_called_once_with(['-'], cli.Config(
            min='A', max='F', exclude=None, ignore=None, show_complexity=False,
            average=False, order=getattr(cc_mod, 'SCORE'), no_assert=False,
            total_average=False, show_closures=False))
        log_mock.assert_called_once_with(mock.sentinel.harvester, codeclimate=False, json=True,
                                         xml=False)
Beispiel #6
0
 def testCall(self):
     cc(TEST_DIR, **self.params)
Beispiel #7
0
 def testCall(self):
     cc(TEST_DIR, **self.params)