Skip to content

Commit 1fbf2e6

Browse files
committed
initial revision
0 parents  commit 1fbf2e6

File tree

14,513 files changed

+3314240
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

14,513 files changed

+3314240
-0
lines changed

BUGS.txt

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
NiCad 7.0, January 2024
2+
3+
Please report any bugs or problems with NiCad in GitHub.
4+
5+
Known Issues:
6+
-------------
7+
8+
1. Syntax Errors
9+
-------------
10+
In order to do its work, NiCad parses all source files.
11+
Often systems will have some files with real syntax errors in them,
12+
so do not be alarmed by a small number of "failed to parse" files,
13+
that is normal and expected.
14+
15+
However, if you get a large number of parse errors (more than 1%),
16+
please report details of the problem in GitHub so that the grammars
17+
can be improved.
18+
19+
2. Directory and File Names with Strange Characters
20+
------------------------------------------------
21+
Some systems allow directories with strange characters in them.
22+
These can present a problem for the NiCad scripts, which use find(1)
23+
to navigate large directories of source.
24+
25+
To process systems like this, first run the "fixfilenames" command
26+
in the NiCad home directory on the system source. For example:
27+
28+
fixfilenames systems/c/thesystem
29+
30+
3. Output is not pure XML
31+
----------------------
32+
The output of NiCad is in its own simple markup format based on XML,
33+
but is not pure XML. In particular, it is missing the XML schema header line.
34+
However, it is close enough that it should be acceptable to any XML editor.
35+
36+
When source is included in the results (the "withsource" output produced
37+
by the "report=yes" configuration option), source fragments may cause
38+
problems for XML editors. However, the HTML format of the results is pure
39+
XHTML and should be acceptable to any web browser.
40+
41+
Rev 15.1.24

LICENSE.txt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
NiCad clone detection system, Version 7.0
2+
J.R. Cordy, January 2024
3+
4+
Copyright 2024, James R. Cordy and others
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
7+
and associated documentation files (the “Software”), to deal in the Software without restriction,
8+
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
9+
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all copies
13+
or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
17+
AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Makefile

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Recompile all NiCad tools and plugins
2+
3+
# Usage:
4+
# make [options]
5+
#
6+
# where options can be one or more of:
7+
#
8+
# MACHINESIZE=-mXX - Force XX-bit tools, where XX=32 or 64 (default: system default)
9+
#
10+
# SIZE=NNNN - Compile TXL plugins to size -s NNNN (default: 400, max: 4000)
11+
# (warning: larger sizes use more memory and slows syntax error recovery)
12+
#
13+
14+
# Localization
15+
OS := $(shell (uname -s | sed 's/_.*//'))
16+
17+
MESSAGE = "Unrecognized platform - making Nicad using gcc and no signal handling"
18+
19+
ifeq ($(OS), Darwin)
20+
MESSAGE = "Making Nicad on MacOS using gcc and BSD signal handling"
21+
CFLAGS := $(CFLAGS) -mmacosx-version-min=10.12
22+
LDFLAGS := $(LDFLAGS) -mmacosx-version-min=10.12
23+
SIGTYPE = BSD
24+
25+
else ifeq ($(OS), Linux)
26+
MESSAGE = "Making Nicad on Linux using gcc and BSD signal handling"
27+
CFLAGS := $(CFLAGS) -Wno-format-truncation -Wno-format-overflow -Wno-unused-result
28+
SIGTYPE = BSD
29+
30+
else ifeq ($(OS), CYGWIN)
31+
MESSAGE = "Making Nicad on Cygwin using gcc and BSD signal handling"
32+
CFLAGS := $(CFLAGS) -Wno-stringop-overread -Wno-stringop-overflow
33+
LDFLAGS := $(LDFLAGS) -Wl,--stack,8388608
34+
EXE = .exe
35+
SIGTYPE = BSD
36+
37+
else ifeq ($(OS), MSYS)
38+
MESSAGE = "Making Nicad on Msys / MinGW using gcc and BSD signal handling"
39+
CFLAGS := $(CFLAGS) -Wno-stringop-overread -Wno-stringop-overflow
40+
LDFLAGS := $(LDFLAGS) -Wl,--stack,8388608
41+
EXE = .exe
42+
SIGTYPE = BSD
43+
44+
else ifeq ($(OS), MINGW64)
45+
MESSAGE = "Making Nicad on Msys / MinGW using gcc and BSD signal handling"
46+
LDFLAGS := $(LDFLAGS) -Wl,--stack,8388608
47+
EXE = .exe
48+
SIGTYPE = BSD
49+
endif
50+
51+
# Build
52+
all: clean lib/nicad/scripts lib/nicad/tools lib/nicad/txl lib/nicad/config
53+
54+
lib/nicad/tools:
55+
mkdir -p lib/nicad/tools
56+
(cd src/tools; make)
57+
cp src/tools/*.x lib/nicad/tools/
58+
59+
lib/nicad/txl:
60+
mkdir -p lib/nicad/txl
61+
(cd src/txl; make)
62+
cp src/txl/*.x lib/nicad/txl/
63+
64+
lib/nicad/scripts:
65+
mkdir -p lib/nicad/scripts
66+
cp src/scripts/* lib/nicad/scripts
67+
68+
lib/nicad/config:
69+
mkdir -p lib/nicad/config
70+
cp src/config/* lib/nicad/config
71+
72+
# Make distribution release for this platform
73+
74+
distrib : lib/nicad/tools lib/nicad/txl lib/nicad/scripts lib/nicad/config
75+
/bin/rm -rf nicad-$(OS)
76+
mkdir -p nicad/bin
77+
cp bin/* nicad/bin/
78+
mkdir -p nicad/lib
79+
cp -r lib/* nicad/lib/
80+
cp -r src/installer/* nicad/
81+
cp *.txt nicad/
82+
mv nicad nicad-$(OS)
83+
tar cfz nicad-$(OS).tar.gz nicad-$(OS)
84+
85+
clean:
86+
(cd src/tools; make clean)
87+
(cd src/txl; make clean)
88+
/bin/rm -rf lib/*
89+
/bin/rm -rf nicad-$(OS)
90+
/bin/rm -f nicad-$(OS).tar.gz
91+
/bin/rm -rf nicadclones

QUESTIONS.txt

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
NiCad 7.0, January 2024
2+
3+
Questions and answers about NiCad can be found in the
4+
NiCad discussion forum on the TXL website:
5+
6+
http://www.txl.ca/forum/viewforum.php?f=28
7+
8+
Frequently asked questions:
9+
10+
1. What types of clones does NiCad detect?
11+
12+
NiCad detects clone types 1-3.
13+
14+
To detect type 1 (exact) clones, set threshold=0.0
15+
To detect type 2 (renamed) clones, set threshold=0.0 and rename=blind
16+
To detect type 2c (consistently renamed) clones, set threshold=0.0 and rename=consistent
17+
To detect type 3-1 (near-miss exact) clones, set threshold=0.3
18+
To detect type 3-2 (near-miss renamed) clones, set threshold=0.3 and rename=blind
19+
To detect type 3-2c (near-miss consistently renamed) clones, set threshold=0.3 and rename=consistent
20+
21+
Predefined configurations for each of these NiCad configurations
22+
are in the config/ subdirectory. Predefined configurations include
23+
type1, type2, type2c, type3-1, type3-2, type3-c, corresponding to the
24+
options above.
25+
26+
For example, to detect only type 1 (exact) clones in the JHotDraw54b1
27+
example system, use the NiCad command:
28+
29+
nicad6 functions java examples/JHotDraw54b1 type1
30+
31+
Note that results are inclusive, that is, type 2 includes type 1,
32+
type 3-1 includes type 1, and type 3-2 includes types 1 and 2.
33+
34+
2. What languages does NiCad handle?
35+
36+
NiCad comes with plugins to handle C, Java, C#, Python, PHP, Ruby,
37+
Swift, ATL and WSDL, but can handle any language easily.
38+
39+
Any other language L for which there is a TXL grammar can be
40+
added by creating simple "L-extract-functions.txl" and
41+
"L-extract-blocks.txl" TXL programs to extract the corresponding
42+
code fragments from an L program.
43+
44+
3. What code fragment granularities can NiCad handle?
45+
46+
NiCad comes with plugins to detect function (method) and block
47+
(compound statement) clones.
48+
49+
Other granularities can easily be added by creating simple variants
50+
of the TXL extractor plugins for other code units.
51+
52+
4. What forms of output does NiCad produce?
53+
54+
NiCad produces clone pairs in XML-like format specifying the
55+
source file and starting and ending line numbers of each original
56+
source fragment in the pair, for example:
57+
58+
<clone nlines="42" similarity="100">
59+
<source file="EGsystem/EGfile1.java" startline="477" endline="529" pcid="596"></source>
60+
<source file="EGsystem/EGfile2.java" startline="417" endline="470" pcid="595"></source>
61+
</clone>
62+
63+
If the NiCad configuration includes "report=yes", additional reports
64+
in both XML and browser-compatible HMTL web page form are produced
65+
with original source code for each fragment.
66+
67+
5. Can NiCad cluster clone pairs into clone classes?
68+
69+
NiCad can optionally cluster clone pairs into clone classes by
70+
including "cluster=yes" in the configuration file. Each clone class
71+
consists of the largest set of detected source fragments that are related
72+
to one another by at least one clone pair.
73+
74+
6. What normalization and other clone detection options does NiCad support?
75+
76+
NiCad includes configuration options to customize clone detection
77+
to filter (ignore) or abstract (treat as same) any part of the code.
78+
79+
For example, to ignore declarations, make a NiCad configuration
80+
including "filter=declaration", or to treat all expressions as
81+
equivalent, make a NiCad configuration including "abstract=expn".
82+
83+
Custom normalizations can be added to custom transform the code
84+
in any way you wish before comparison using "normalize=mytransform",
85+
where "mytransform.txl" is any TXL source transformation you wish
86+
to add.
87+
88+
7. Can NiCad find clones between two different systems?
89+
90+
NiCad can detect cross-clones between two different systems
91+
using the command "nicadcross", which reports only clones that
92+
cross between two different systems.
93+
94+
If you require both clones inside the systems and between them,
95+
put symbolic links to the root source directories of both of the systems
96+
in a parent directory and use the regular "nicad" command on that directory.
97+
98+
Rev 15.1.24

0 commit comments

Comments
 (0)