Questions tagged [code-metrics]

Software metrics are quantitative data pertaining to source code, e.g. number of lines of code (LOC) for a file.

Questions with this tag will often be about which metrics are most useful for certain purposes or which tools are available to provide certain metrics.

276 questions
2
votes
2 answers

Is there a way to compare or do a delta of VS 2010 Code Analysis, Metrics and Code Coverage results?

I have started to work with the Code Measurement and Analysis features of VS2010; i.e. the code analysis, code metrics and code coverage. I have gone through the details about how to run these tools (using VS and automate via the command line) and…
Lalman
  • 946
  • 2
  • 11
  • 27
2
votes
1 answer

How to count generated lines of code in Visual Studio?

I'm working on a project in which the majority of the code is generated. I'm fully aware of what a useless metric SLOC is, but I'd like to brag about how much work and potential human error the code generators are saving as a KPI to dazzle the…
Kevin Krumwiede
  • 9,868
  • 4
  • 34
  • 82
2
votes
1 answer

counting source code lines in python project

How do I calculate the number of lines written in a project containing multiple sub dirs in a python project. for example a dir structure is like A \ <*some files here*>\ B \ <*some files here*>\ ... and so on...
daydreamer
  • 87,243
  • 191
  • 450
  • 722
2
votes
3 answers

How to calculate code metrics in Visual Studio Code?

Apparently there is an 'analyse' tab to be able to view the metrics but I can't see it,(using latest version) don't think its in this version. I already have LOC as I downloaded an extension but how would I get other metrics? Languages are Java, CSS…
Kirsty Liv
  • 25
  • 1
  • 5
2
votes
8 answers

How do you define 'unwanted code'?

How would you define "unwanted code"? Edit: IMHO, Any code member with 0 active calling members (checked recursively) is unwanted code. (functions, methods, properties, variables are members)
NileshChauhan
  • 5,469
  • 2
  • 29
  • 43
2
votes
1 answer

Expose metrics from spring application to prometheus without using spring-boot actuator

I have been trying to collect micrometer metrics in a non springboot application and expose them to prometheus.I have added the following dependency and the test method for the same.I would like to know how to proceed and expose the collected…
2
votes
2 answers

How come the maintainability index of a project decreases even though cyclomatic complexity, class coupling and lines of code have decreased?

For a C# project of mine the code metrics delta after a refactoring are: Maintability Index: -4 Cyclomatic Complexity: -48 Depth of Inheritance: 0 Class Coupling: -9 Lines of Code: -85 How come the Maintainability Index has decreased when the…
Christian
  • 7,433
  • 4
  • 36
  • 61
2
votes
3 answers

How to remove unused code in IntelliJ IDEA?

In IntelliJ, in a .java file, some unused code is greyed out indicating that the declared variable or function is never used. Unused imports are removed using Ctrl+Alt+O. Is there any shortcut to remove those unused declarations?
mustang
  • 105
  • 1
  • 2
  • 11
2
votes
0 answers

Prometheus Adapter empty custom metric items

I'm attempting to auto-scale a Kubernetes deployment with an HPA using Prometheus custom metrics with the Prometheus Adapter. These custom metrics are published to Prometheus via another deployment in another namespace which every minute queries a…
2
votes
2 answers

Lines of Code as a function of preprocessor definitions

A project I'm working on (in C) has a lot of sections of code that can be included or omitted based on compile-time configuration, using preprocessor directives. I'm interested in estimating how many lines of code different configurations are…
Ziv
  • 2,369
  • 3
  • 24
  • 40
2
votes
0 answers

Exclude generated code from Scaffolded DbContext from Code Metrics Results

I am working on a asp.net core 2.2 web api project. I have a separate class library called MyProject.Db that I have scaffolded the db context from an existing database. The MyProjDbContext contains an auto-generated method called protected override…
2
votes
2 answers

Computational complexity for regular expressions

Regular expressions rapidly become too complex (for me) to understand. Even something so simple as [ab][cd], has several logical branches. My goal is to improve the maintainability of our code base, so answers to these questions could help us…
2
votes
1 answer

How does VS Code metrics do the math

I've been digging around and I can't get an answer that convinced me. Until recently I thought that the number of lines of code depend only on the complete lines of code, I mean, every line of code with a real purpose which is more or less what MSDN…
jorge.armando
  • 50
  • 1
  • 7
2
votes
1 answer

SourceMonitor using C and C++ at same project

Using SourceMonitor xml command file, I'm trying to analyze a whole checked out repository from Git that I know for a fact that it has both C and C++ code in the same directory. This a snippet of my XML command file.
Nerminz
  • 27
  • 6
2
votes
2 answers

Is it possible to use NDepend to find class partitioning in an OOP language?

Fort first let me better explain the context and the problem. Context We have a big class with dozen of methods; it violates many Software Engineering principles and this is clearly visible through a code metrics measure tool. See poor cohesion, too…
Revious
  • 7,816
  • 31
  • 98
  • 147