Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-21848

CyclomaticComplexity/LineOfCodes always 0 if library contains enumeration

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • vs-code-metrics-plugin
    • VM with Windows 7 (x64), used as Master and Build Jenkins, Visual Studio 2010, Metrics-Version: 10.0

      The codemetric displays CyclomaticComplexity/LineOfCodes always 0 if the checked library contains an enumeration with calculated CC/LoC = 0 (there are multiple lines of code in the enumeration), see attached image vsCodeMetrics_1.png.

      CodeMetrics calculation result in VS2010 shows the same values for the ExampleEnum, but the CC/LoC at upper levels shows a value != 0, see image vsMetrics_1.png.

      Level 1: checked .dll
      Level 2: namespace
      Level 3: classes/enums

      Example Enum:
      /// <summary>...</summary>
      public enum ExampleEnum

      { A, B }

          [JENKINS-21848] CyclomaticComplexity/LineOfCodes always 0 if library contains enumeration

          Is it possible to check the value of CyclomaticComplexity of Metrics.xml ?

          Yasuyuki Saito added a comment - Is it possible to check the value of CyclomaticComplexity of Metrics.xml ?

          Kris P added a comment -

          Here is the content for one of those Enums:
          ================================================
          <Type Name="SomeEnumType">
          <Metrics>
          <Metric Name="MaintainabilityIndex" Value="100" />
          <Metric Name="CyclomaticComplexity" Value="0" />
          <Metric Name="ClassCoupling" Value="0" />
          <Metric Name="DepthOfInheritance" Value="1" />
          <Metric Name="LinesOfCode" Value="0" />
          </Metrics>
          <Members />
          </Type>
          ================================================
          .pdb file is in the same folder with the dll-file, no warnings or errors while running "Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\Metrics.exe"

          Any advices how to produce more possible helpfull logs?

          Kris P added a comment - Here is the content for one of those Enums: ================================================ <Type Name="SomeEnumType"> <Metrics> <Metric Name="MaintainabilityIndex" Value="100" /> <Metric Name="CyclomaticComplexity" Value="0" /> <Metric Name="ClassCoupling" Value="0" /> <Metric Name="DepthOfInheritance" Value="1" /> <Metric Name="LinesOfCode" Value="0" /> </Metrics> <Members /> </Type> ================================================ .pdb file is in the same folder with the dll-file, no warnings or errors while running "Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\Metrics.exe" Any advices how to produce more possible helpfull logs?

          Do you know the cyclomatic complexity of Module and Namespace that contains the enumeration in the file?

          if cyclomatic complexity is 0, there is a possibility of failure of Metrics.exe.
          Otherwise, it is a bug in the plug-in.

          Yasuyuki Saito added a comment - Do you know the cyclomatic complexity of Module and Namespace that contains the enumeration in the file? if cyclomatic complexity is 0, there is a possibility of failure of Metrics.exe. Otherwise, it is a bug in the plug-in.

          Julian H. added a comment - - edited

          I have the same issue here with the Visual Studio Code Metrics Powertool for Visual Studio 2013. Are there any solutions?
          Update: It seems that this has to do with the metrics.exe itself. I tested this by executing metrics.exe manually. There were the same "<Metric Name="LinesOfCode" Value="0" />" metric elements as in the Jenkins generated output.

          Julian H. added a comment - - edited I have the same issue here with the Visual Studio Code Metrics Powertool for Visual Studio 2013. Are there any solutions? Update: It seems that this has to do with the metrics.exe itself. I tested this by executing metrics.exe manually. There were the same "<Metric Name="LinesOfCode" Value="0" />" metric elements as in the Jenkins generated output.

          Christian Altmeier added a comment - - edited

          Hi there!

          Same problem here. But: It seems that the powertool summarize the cyclomatic complexity for the whole module. The result is in our case a very high cyclomatic complexity of "11.580" in "26.060" lines of code. Is it possible, that the plugin cannot parse these strings with high metric values to integers? Wether the cyclomatic complexity nor the lines of code and class coupling are displayed in graphs in tables for the views "All classed" and "Code metrics by module".

          Here is our modules metrics node from the powertool XML:

          <Metrics>
          <Metric Name="MaintainabilityIndex" Value="83" />
          <Metric Name="CyclomaticComplexity" Value="11.580" />
          <Metric Name="ClassCoupling" Value="969" />
          <Metric Name="DepthOfInheritance" Value="7" />
          <Metric Name="LinesOfCode" Value="26.060" />
          </Metrics>

          The single members and types are correctly parsed by the plugin an shows correct values in both tables and graph.

          I think i can provide the whole XML file, if this helps to improve the plugin.

          By the way: Thanks for this convenient plugin wich allows to gather code metrics in Jenkins so easily!

          UPDATE: Meanwhile i have tested also with the metrics tool from Visual Studio 2012 (Version 11). Same behavior. The plugin doesn't read the module metrics from the code metrics xml file.

          Christian Altmeier added a comment - - edited Hi there! Same problem here. But: It seems that the powertool summarize the cyclomatic complexity for the whole module. The result is in our case a very high cyclomatic complexity of "11.580" in "26.060" lines of code. Is it possible, that the plugin cannot parse these strings with high metric values to integers? Wether the cyclomatic complexity nor the lines of code and class coupling are displayed in graphs in tables for the views "All classed" and "Code metrics by module". Here is our modules metrics node from the powertool XML: <Metrics> <Metric Name="MaintainabilityIndex" Value="83" /> <Metric Name="CyclomaticComplexity" Value="11.580" /> <Metric Name="ClassCoupling" Value="969" /> <Metric Name="DepthOfInheritance" Value="7" /> <Metric Name="LinesOfCode" Value="26.060" /> </Metrics> The single members and types are correctly parsed by the plugin an shows correct values in both tables and graph. I think i can provide the whole XML file, if this helps to improve the plugin. By the way: Thanks for this convenient plugin wich allows to gather code metrics in Jenkins so easily! UPDATE: Meanwhile i have tested also with the metrics tool from Visual Studio 2012 (Version 11). Same behavior. The plugin doesn't read the module metrics from the code metrics xml file.

          Thomas T added a comment -

          This bug is really annoying and basically of this we don't use the plugin. Is the plugin development in any way active?
          I acknowledge the post from Christian Altmeier. It seems that the problem is when the values are to high.

          Thomas T added a comment - This bug is really annoying and basically of this we don't use the plugin. Is the plugin development in any way active? I acknowledge the post from Christian Altmeier. It seems that the problem is when the values are to high.

            Unassigned Unassigned
            kp_k_m Kris P
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: