A code similarity report is a ranked list of matches between one submission and every other file in a corpus, plus whatever web and AI signals the tool attaches to it. The percentage beside each match measures shared token sequences. It is not a verdict, and it is not a probability that anyone cheated. Students who learn to read one before they submit make fewer of the mistakes that end up in front of an academic integrity board, and they learn something about provenance in the process.
What follows is the workflow from a Java data structures course, roughly 180 students per section across three sections, that we ran for three semesters starting in Fall 2022. It includes the configuration details, the numbers, and the parts that did not go as planned.
What the number on a code similarity report actually measures
Most tools in this space, including MOSS (Aiken, Stanford, since 1994), JPlag (now at 5.x, rewritten in Kotlin for the 2023 release), Dolos, and Codequiry, do some version of the same thing at the base layer: strip comments and whitespace, tokenize the source, and fingerprint overlapping k-gram sequences. The winnowing scheme described by Schleimer, Wilkerson, and Aiken in their 2003 SIGMOD paper is still the clearest explanation of why this works. You keep a selected subset of hashed k-grams and match on those, which makes the comparison resistant to reformatting and variable renaming while staying fast enough to run a thousand submissions against each other.
Two files that look nothing alike to a text diff can be identical to a token stream. This pair scores near zero on a line comparison and near 100% on a token comparison:
// Submission A
for (int i = 0; i < n; i++) { total += arr[i]; }
// Submission B
for (int idx = 0; idx < count; idx++) { sum += values[idx]; }
That property is the whole point of a source code plagiarism checker, and it is also the source of most student confusion. The number does not say the files look the same. It says they are the same after the tool normalizes them.
Step 1. Fix the corpus before you touch the threshold
Every false positive I have chased in six years traces back to a corpus definition problem. Provided code, starter repositories, library files, and test harnesses all get matched, and they get matched identically in every submission that uses them.
In the Spring 2023 pilot we forgot to exclude the provided Main.java scaffold, which was 41 lines of menu-driven I/O that students were told not to modify. Sixty-one of 94 submissions came back at 100% peer similarity. The report was technically correct and completely useless. We spent a TA-week explaining why nothing was wrong.
The fix is boring and it works. Adopt a naming convention for provided files (provided_Main.java, provided_IOHelper.java) and treat the exclusion list as a config file under version control, not something a TA re-types each assignment.
# selfcheck/manifest.py
from pathlib import Path
PROVIDED = {"Main.java", "IOHelper.java", "GivenTests.java"}
SKIP_DIRS = {".git", "target", "build", "__pycache__", ".idea"}
def collect(root):
keep = []
for p in Path(root).rglob("*.java"):
if set(p.parts) & SKIP_DIRS:
continue
if p.name in PROVIDED:
continue
keep.append(p)
return keep
If the tool supports a base document or reference submission, upload the provided scaffold there as well. Belt and braces, for the same reason you keep a .gitignore and a .dockerignore.
Step 2. Pick a minimum match length that fits the language
A raw similarity percentage is nearly meaningless without a minimum match length. Twenty tokens of shared code in a 70-line assignment is noise. Twenty tokens in a 900-line project is not even a method. The tools that let you set a noise threshold (k in the winnowing literature, typically 15 to 25 tokens) and a guarantee threshold (t, the shortest match you promise to report, typically 8 to 12) are the ones you can calibrate.
For intro Java we settled on k = 15 and t = 8 after a semester of fiddling. Your mileage depends heavily on how much boilerplate your assignments carry. An assignment that requires six getters and setters will generate identical blocks in every correct submission, and in IntelliJ the generated equals() and hashCode() blocks are byte-for-byte the same across everyone who pressed Alt+Insert.
| Longest matched run | Usual cause | What we do |
|---|---|---|
| Under 25 tokens | getters, imports, main scaffolding, IDE-generated methods | Ignore, or exclude the file |
| 25 to 80 tokens | one helper method or loop body | Read the pair side by side, then ask both students separately |
| Over 80 tokens | a full function or class, often several in the same order | Open a case file; request working-session history |
That table is the single most useful artifact I have handed a new TA. It converts a percentage into a workload decision in about four seconds.
Step 3. Run a self-check window, not a pre-accusation
Seventy-two hours before the deadline, we opened a check that students could run against themselves. The rules were simple: two runs maximum, the report is visible only to the student, and the TA sees who ran it but not what it contained. Anything submitted after the window closes goes through review without the student having seen their own report.

The mechanics matter less than the framing. Students who think the report is a trap will not use it. We described it in the syllabus as a spell-checker for originality and said explicitly that seeing a 45% match and doing nothing about it is worse than not running the check at all.
For a team that wants this automated, the check can be kicked off from a script or a CI job rather than a dashboard, which also helps when the assignment lives in a Git-based submission system:
import os, requests
resp = requests.post(
"https://codequiry.com/api/v2/check/start",
headers={"apikey": os.environ["CODEQUIRY_KEY"]},
json={
"name": "cs210-p5-selfcheck",
"language": "java",
"visibility": "private",
},
timeout=30,
)
print(resp.status_code, resp.json())
Field names shift between API versions, so read the current docs before wiring this into anything that pages a TA at 2 a.m.
Step 4. Spend twenty minutes of class on how to read the thing
This is the part most courses skip, and it is the part that changes behavior. We put one anonymized, consented student pair on the projector: same assignment, 68% peer similarity, matched across two methods. Then we walked through three questions, in this order.
- What matched? File, line range, token count. Not the percentage.
- Why did it match? Shared scaffold, shared textbook source, a cited web page, or a shared working session.
- What are you going to do about it? Cite it, rewrite it, or leave it and attach a note.
The third question is where students get stuck, and it is where the pedagogy actually lives. A student who copied a loop from a tutorial and cited it has done nothing wrong. A student who copied a loop from a tutorial and cannot explain the loop has done something wrong that has nothing to do with attribution.

Here is the distribution from three semesters, n = 1,148 self-checks out of 1,402 total submissions, an 82% participation rate.
| Peer score at self-check | Share of self-checks | Revised before deadline | Flagged after review |
|---|---|---|---|
| 0 to 15% | 63% (723) | 4% | 0.9% |
| 16 to 30% | 24% (276) | 38% | 6.1% |
| 31 to 50% | 9% (103) | 71% | 19.4% |
| Above 50% | 4% (46) | 88% | 41.3% |
Read the last two columns carefully. Roughly 71% of students in the 31 to 50% band revised something before the deadline, and 19% of that band still ended up flagged after human review. The window did not solve the problem. It moved a large share of it earlier, where the cost of a fix is fifteen minutes instead of a hearing.
Overall, 11.2% of non-participating submissions were flagged (n = 254) against 3.4% of participating ones. I would not read that as a causal effect. Students who opt into a self-check differ from students who don't in ways I can't measure, starting with the fact that they read the syllabus.

Step 5. Make attribution a graded artifact, not an apology
If you want students to cite code, give it a format and give it points. We put a 5% weight on a provenance section worth three points out of sixty, and the quality of the comments went up sharply after the first semester, mostly because students finally knew what we wanted.
// Attribution: the recursive descent below follows the structure of
// GeeksforGeeks, "Iterative Preorder Traversal" (accessed 2024-02-11),
// adapted to use our Stack<Node> class instead of java.util.ArrayDeque.
// Original contribution: the null-child guard on lines 41-47.
That comment does four things at once. It names the source, gives a date, states what changed, and separates the student's contribution from the borrowed part. It is also, roughly, what a good commit message looks like in industry, which is worth saying out loud to a room of sophomores.
Step 6. Decide what happens when the window closes
A match is a question. The report does not know why two files are similar, and no scoring change will fix that. Our rule was two reviewers on anything above 40% peer similarity and a written note from each student before anyone used the word plagiarism in an email.
We stopped treating the report as a finding about twelve months in. It is a triage list. The finding is what comes out of the conversation, and that takes a human being every time.
Of the 41 submissions flagged above 50% across the three semesters, nine turned out to be legitimate: five were students who had been told they could work in pairs and misunderstood the submission rule, two had a provided file that slipped past our exclusion list because a student renamed it, and two were the IntelliJ-generated equals() and hashCode() pair I mentioned earlier, which produced a 34-line identical block between two students who had never met.
That last one is worth teaching directly. Show students the report at 100% on a file they know they wrote themselves, and let them see what it feels like before they ever have to argue about it.
What the similarity report does not tell you
Peer similarity and web similarity compare a submission against other things that exist in a corpus. A file generated wholesale by an LLM and never shared with a classmate matches nothing. It can score 0% peer, 0% web, and still be entirely machine-written.
This is the gap most courses get caught by in 2024 and 2025. The two signals answer different questions and you need both in the same submission view, which is the main reason we consolidated onto AI code detection that runs alongside the peer and web checks rather than as a separate semester-end export that nobody reconciles. If your current tool does one and not the other, you are running half a check and calling it a policy.
Caveats worth stating plainly
Three semesters, one department, three TAs, and a self-selected treatment group. The revision rates in the table are descriptive, not experimental. We have not tested whether the twenty minutes of class instruction does anything on its own, separate from the window, which is the study I would run next if I had a free fall.
And the tooling is not neutral. A token-based code plagiarism checker for teachers will surface a legitimate pair of pair-programmers at 60% and let a determined refactorer through at 12%. The threshold catches the careless, not the adversarial. Design assignments accordingly, and keep a human on the other end of the report.
Frequently Asked Questions
What similarity percentage counts as plagiarism in code?
None, on its own. In our course, 40% peer similarity triggered a review, not a finding. On short assignments with heavy boilerplate, 40% is often routine. On a 900-line project it is worth a conversation.
Should students see their similarity score before they submit?
We think so, capped at two runs and framed as a formative check. Participation sat at 82% and the revision rate in the 31 to 50% band was 71%, which is a lot of problems fixed before anyone opened a case file.
Does renaming variables defeat a code similarity report?
Not against token-based or AST-based comparison. Renaming identifiers, reformatting, and reordering independent statements change almost nothing in the token stream. Rewriting the logic from scratch does, which is the behavior you were trying to encourage anyway.
Can a similarity report detect code written by ChatGPT?
Not peer similarity or web similarity, because both compare against a corpus and a generated file may exist nowhere else. AI code detection is a separate signal, scored per file, and it belongs in the same report as the other two so a reviewer sees one picture.
If you want to see how the peer, web, and AI signals look side by side on a real cohort, the code plagiarism checker runs all three in a single check, with a review queue that ranks submissions by how far they sit from the rest of the class.