# Identifier Elements

All identifier queries produce identifier lists data as their result. Clicking on an identifier in the list will lead you to a page like the following.

## Identifier: copy_file Read-only: No Tag for struct/union/enum: No Member of struct/union: No Label: No Ordinary identifier: Yes Macro: No Undefined macro: No Macro argument: No File scope: No Project scope: Yes Typedef: No Enumeration constant: No Function: Yes Crosses file boundary: Yes Unused: No Matches 5 occurence(s) Appears in project(s): cp The identifier occurs (wholy or in part) in function name(s): copy_file - function page Substitute with: ### Dependent Files (Writable)
Directory | File
--- | ---
/vol/src/bin/cp/ | cp.c | marked source
/vol/src/bin/cp/ | extern.h | marked source
/vol/src/bin/cp/ | utils.c | marked source
### Dependent Files (All)
Directory | File
--- | ---
/vol/src/bin/cp/ | cp.c | marked source
/vol/src/bin/cp/ | extern.h | marked source
/vol/src/bin/cp/ | utils.c | marked source
Main page - Web: Home Manual CScout 2.0 - 2004/07/31 12:37:12

As you see, for each identifier CScout will display:

- If the identifier is read-only (i.e. it appears in at least one read-only file)
- The C namespace(s) it appears in (the same identifier can be a member of multiple namespaces)
- Whether the identifier is visible at file or project scope
- Whether the identifier is a `typedef` (`typedef`'s belong to the ``ordinary identifier'' namespace, but are obviously important, so CScout will tag them as such).
- Whether the identifier crosses a file boundary, i.e. it appears in more than one file
- Whether the identifier is unused i.e. it appears in exactly one location
- The identifier's number of occurences in all the workspace's files
- The projects the identifier appears in
- The function names the identifier forms; the link "function page" will provide you more details regarding the function
- An option to substitute the identifier's name with a different name

The substitution will globally replace the identifier (or the identifier part) in all namespaces, files, and scopes required for the program to retain its original meaning. No checks for name collisions are made, so ensure that the name you specify is unique for the appropriate scope. Performing the substitution operation will not change the identifier's name in the current invocation of CScout. However, once you have finished your browsing and replacing session, you have an option to terminate CScout and write back all the subtitutions you made to the respective source files.

Finally, the identifier's page will list the writable and all files the specific identifier appears in. Clicking on the ``marked source'' hyperlink will display the respective file's source code with only the given identifier marked as a hyperlink. By pressing your browser's tab key you can then see where the given identifier is used. In our example the `cp.c` source code with the `copy_file` identifier marked would appear as follows:

case S_IFBLK: case S_IFCHR: if (Rflag) { if (copy_special(curr->fts_statp, !dne)) badcp = rval = 1; } else { if (copy_file(curr, dne)) badcp = rval = 1; } break; case S_IFIFO: if (Rflag) { if (copy_fifo(curr->fts_statp, !dne)) badcp = rval = 1; } else { if (copy_file(curr, dne)) badcp = rval = 1; } break; default: if (copy_file(curr, dne)) badcp = rval = 1; break; }

## Identifier Metrics

The identifier metrics page displays a summary of metrics related to identifier use. In our example, the metrics are as follows:

## Identifier Metrics ### Writable Identifiers
Identifier class | Distinct # ids | Total # ids | Avg length | Min length | Max length
--- | --- | --- | --- | --- | ---
All identifiers | 1439 | 10472 | 3.72272 | 1 | 17
Tag for struct/union/enum | 10 | 24 | 4.7 | 2 | 9
Member of struct/union | 56 | 721 | 4.21429 | 1 | 10
Label | 7 | 16 | 5.28571 | 2 | 9
Ordinary identifier | 1149 | 8342 | 3.51175 | 1 | 17
Macro | 185 | 1298 | 5.16216 | 2 | 10
Undefined macro | 2 | 2 | 8.5 | 6 | 11
Macro argument | 30 | 69 | 1 | 1 | 1
File scope | 159 | 1493 | 5.47799 | 2 | 17
Project scope | 277 | 2442 | 6.28881 | 2 | 12
Typedef | 9 | 720 | 5.22222 | 2 | 8
Enumeration constant | 0 | 0 | - | 0 | 0
Function | 177 | 1455 | 6.58192 | 3 | 17
### Read-only Identifiers
Identifier class | Distinct # ids | Total # ids | Avg length | Min length | Max length
--- | --- | --- | --- | --- | ---
All identifiers | 375 | 1180 | 6.36 | 1 | 18
Tag for struct/union/enum | 5 | 14 | 5.4 | 2 | 7
Member of struct/union | 56 | 67 | 7.80357 | 2 | 17
Label | 0 | 0 | - | 0 | 0
Ordinary identifier | 164 | 604 | 6.04878 | 3 | 14
Macro | 116 | 409 | 7.47414 | 2 | 18
Undefined macro | 17 | 154 | 9 | 4 | 15
Macro argument | 33 | 83 | 1.42424 | 1 | 4
File scope | 12 | 131 | 7.25 | 4 | 14
Project scope | 152 | 473 | 5.95395 | 3 | 13
Typedef | 12 | 131 | 7.25 | 4 | 14
Enumeration constant | 0 | 0 | - | 0 | 0
Function | 146 | 449 | 5.84247 | 3 | 10
Main page - Web: Home Manual CScout

You can use these metrics to compare characteristics of different projects, adherance to coding standards, or to identify identifier classes with abnormally short or long names. The ratio between the distinct number of identifiers and the total number of identifiers is the number of times each identifier is used. Notice the difference in our case between the read-only identifiers (which are mostly declarations) and the writable identifiers (which are actually used).

## All identifiers

The all identifiers page will list all the identifiers in your project in alphabetical sequence. In large projects this page will be huge.

## Read-only identifiers

The ``read-only identifiers'' page will only list the read-only identifiers of your project in alphabetical sequence. These typically become part of the project through included header files.

## Writable identifiers

The ``writable identifiers'' page will only list the writable identifiers of your project in alphabetical sequence. These are typically the identifiers your project has defined. In large projects this page will be huge.

## File-spanning writable identifiers

The ``file-spanning writable identifiers'' page will only list your project's identifiers that span a file boundary. Refactoring operations and coding standards typically pay higher attention to such identifiers, since they tend occupy the project's global namespace. In our example, the following page is generated:

### File-spanning Writable Identifiers #### Matching Identifiers PATH_T arg copy_fifo copy_file copy_link copy_special fflag iflag netsettime nflag p_end p_path pflag setfile target_end to usage vary vary_append vary_apply vary_destroy vflag You can bookmark this page to save the respective query Main page CScout 1.6 - 2003/06/04 15:14:51

## Unused project-scoped writable identifiers

The unused project-scoped writable identifiers are useful to know, since they can pinpoint functions or variables that can be eliminated from a workspace.

## Unused file-scoped writable identifiers

The unused file-scoped writable identifiers can also pinpoint functions or variables that can be eliminated from a file. In our example the following list is generated:

### Unused File-scoped Writable Identifiers #### Matching Identifiers copyright copyright copyright rcsid rcsid rcsid rcsid You can bookmark this page to save the respective query Main page CScout 1.6 - 2003/06/04 15:14:51

Notice how distinct identifiers appear as separate entries.

## Unused writable macros

Finally, the unused writable macros page will list macros that are not used within a workspace. In our case the list contains an identifier that was probably used in an earlier version.

### Unused Writable Macros #### Matching Identifiers RETAINBITS You can bookmark this page to save the respective query Main page CScout 1.6 - 2003/06/04 15:14:51

Contents | « Previous Next (Generic Identifier Queries) »