scitools.com

← Metric catalog

Inputs is one of the source-code metrics Understand computes across 17+ languages — browse them in the GUI, export and track them, or script them with the Python API.

Inputs

API ID: CountInput
Also Known As: FANIN (Infomational fan-in)
Languages: C#, C++, Fortran, Java
Targets: Functions, Subprograms

Number of calling subprograms plus global variables read.

The number of inputs a function uses plus the number of unique subprograms calling the function. Inputs include parameters and global variables that are used in the function, so Functions calledby + Parameters read + Global Variables read. Recursive function calls and local variables that are not class static variables are not included. Of the two general approaches to calculating FANIN (informational versus structural) ours is the informational approach.

For example:


int somefunc();

int in = 1;
int out = 1;

int inOutFunc(int in1, int in2, int *inout1, int &inout2, int* out1, int & out2) {
  out = in + in1 + in2 + *inout1 + inout2;

  *inout1 = in1;
  inout2 = in2;

  *out1 = in1;
  out2 = in2;

  in1 = somefunc();
  in2 = 2;

  int randomint = 3;
  in1 = randomint;

  return 4;
}

void callingfunc() {
  int a,b,c,d;
  int myval = inOutFunc(1,2,&a,b,&c,d);
}

inOutFunc reads the global in and the parameters in1, in2, inout1, and inout2, all used together in the expression that sets out. out, out1, and out2 are only ever written, never read, so they don't count, and randomint is a local variable rather than a parameter, global, or class static variable, so it's excluded even though it's used. That's 1 global + 4 parameters read, plus 1 calling function (callingfunc), for an Inputs count of 6.

See Outputs for the related fan-out metric, and the Inputs Metric interactive report to list the references contributing to it for a given function.

Also known as FANIN (Infomational fan-in).

Introduced by Henry, Sallie, and Dennis Kafura in "Software Structure Metrics Based on Information Flow." IEEE Transactions on Software Engineering, vol. SE-7, no. 5, 1981, pp. 510-518.


Targets By Language: