Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 171 additions & 21 deletions plugins/axiomcode/skills/axiomcode/scripts/axiomcode-changed

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
"avoid": ["PlainTests", "CountedTests"]},
{"why": "a renamed overload still reports what the old name's callers lose, and only that overload's",
"run": ["changed", "{repo}", "--old", "{repo}/old.txt", "--new", "{repo}/new-rename.txt", "--file", "src/App/Job.cs", "--impact"],
"want": ["Job.Run src/App/Job.cs:10", "→ impact src/App/Job.cs:10", "Callers.Counted"],
"avoid": ["Callers.Plain", "PlainTests"]}]}
"want": ["Job.Run src/App/Job.cs:10", "→ impact src/App/Job.cs:10", "Callers.Counted", "renamed Run → Execute"],
"avoid": ["Callers.Plain", "PlainTests", "added ", "removed "]}]}
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
"avoid": ["PlainTest", "CountedTest"]},
{"why": "a renamed overload still reports what the old name's callers lose, and only that overload's",
"run": ["changed", "{repo}", "--old", "{repo}/old.txt", "--new", "{repo}/new-rename.txt", "--file", "src/app/Job.java", "--impact"],
"want": ["Job.run src/app/Job.java:8", "→ impact src/app/Job.java:8", "Callers.counted"],
"avoid": ["Callers.plain", "PlainTest"]}]}
"want": ["Job.run src/app/Job.java:8", "→ impact src/app/Job.java:8", "Callers.counted", "renamed run → execute"],
"avoid": ["Callers.plain", "PlainTest", "added ", "removed "]}]}
205 changes: 205 additions & 0 deletions tests/cases/javascript/edits-in-place/case.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
{
"lang": "javascript",
"src": "src",
"checks": [
{
"why": "a method renamed in place (same position, same parameters) is one declaration renamed, answered from the OLD name's callers; never 'removed' plus 'added'",
"run": [
"changed",
"{repo}",
"--old",
"{repo}/old.js",
"--new",
"{repo}/new-rename.js",
"--file",
"src/a.js",
"--impact"
],
"want": [
"signature S.oldName",
"renamed oldName → newName",
"twice",
"use"
],
"avoid": [
"removed ",
"added S.newName",
"signature S.newName"
]
},
{
"why": "a constructor header edit is a signature change of the constructor, found under the name it is written with ('constructor'), not removed and re-added",
"run": [
"changed",
"{repo}",
"--old",
"{repo}/old.js",
"--new",
"{repo}/new-ctor.js",
"--file",
"src/a.js"
],
"want": [
"signature S.<constructor>",
"-b",
"+c"
],
"avoid": [
"removed S.<constructor>",
"added S.constructor",
"-a,",
"placed by name"
]
},
{
"why": "a field added to a destructured parameter names only that field, and targets the constructor (a destructured field is no parameter of its own)",
"run": [
"changed",
"{repo}",
"--old",
"{repo}/old.js",
"--new",
"{repo}/new-destructure.js",
"--file",
"src/a.js"
],
"want": [
"signature S.<constructor>",
"+c",
"impact src/a.js:2"
],
"avoid": [
"-a",
"-b",
"src/a.js:2(c)"
]
},
{
"why": "a multi-line destructured parameter with one field replaced is reported as that one field",
"run": [
"changed",
"{repo}",
"--old",
"{repo}/old-c.js",
"--new",
"{repo}/new-c.js",
"--file",
"src/c.js"
],
"want": [
"signature Auth.<constructor>",
"-jwt",
"+tokens"
],
"avoid": [
"-users",
"-clock",
"removed Auth"
]
},
{
"why": "an edit inside a default value is the function's own parameter change, not a change to the arrow written inside the default",
"run": [
"changed",
"{repo}",
"--old",
"{repo}/old.js",
"--new",
"{repo}/new-default.js",
"--file",
"src/a.js",
"--impact"
],
"want": [
"signature stamp",
"clock: default",
"twice"
],
"avoid": [
"signature millis",
"parameter clock of millis"
]
},
{
"why": "a field whose assignment moved and changed (`this.n = 2` now first in the constructor) is still assigned, so it is not removed",
"run": [
"changed",
"{repo}",
"--old",
"{repo}/old.js",
"--new",
"{repo}/new-reorder.js",
"--file",
"src/a.js"
],
"want": [
"field S.n",
"still assigned"
],
"avoid": [
"removed S.n"
]
},
{
"why": "a graph that already holds the new name reads the old header as that name renamed, never as a 'return type' change",
"run": [
"changed",
"{repo}",
"--old",
"{repo}/old-d.js",
"--new",
"{repo}/new-d.js",
"--file",
"src/d.js"
],
"want": [
"renamed stale → fresh"
],
"avoid": [
"return type"
]
},
{
"why": "control: a body edit is a body change of that method, and no field of the constructor is touched",
"run": [
"changed",
"{repo}",
"--old",
"{repo}/old.js",
"--new",
"{repo}/new-body.js",
"--file",
"src/a.js"
],
"want": [
"body S.oldName"
],
"avoid": [
"signature ",
"removed ",
"field "
]
},
{
"why": "control: a statement added to a constructor body leaves its header and its untouched field this.name alone",
"run": [
"changed",
"{repo}",
"--old",
"{repo}/old.js",
"--new",
"{repo}/new-errbody.js",
"--file",
"src/a.js"
],
"want": [
"body Err.<constructor>"
],
"avoid": [
"Err.name",
"signature ",
"removed "
]
}
]
}
27 changes: 27 additions & 0 deletions tests/cases/javascript/edits-in-place/new-body.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export class S {
constructor({ a, b }) {
this.a = a;
this.b = b;
this.n = 1;
}

async oldName(x, y) {
const s = x + y;
return s * 2;
}

keep(v) {
return v;
}
}

export function stamp(v, clock = { millis: () => Date.now() }) {
return { v, at: clock.millis() };
}

export class Err extends Error {
constructor(msg) {
super(msg);
this.name = 'Err';
}
}
15 changes: 15 additions & 0 deletions tests/cases/javascript/edits-in-place/new-c.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export class Auth {
constructor({
users,
tokens,
clock,
}) {
this.users = users;
this.tokens = tokens;
this.clock = clock;
}

check(token) {
return this.tokens.verify(token);
}
}
26 changes: 26 additions & 0 deletions tests/cases/javascript/edits-in-place/new-ctor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export class S {
constructor({ a, c }) {
this.a = a;
this.c = c;
this.n = 1;
}

async oldName(x, y) {
return x + y;
}

keep(v) {
return v;
}
}

export function stamp(v, clock = { millis: () => Date.now() }) {
return { v, at: clock.millis() };
}

export class Err extends Error {
constructor(msg) {
super(msg);
this.name = 'Err';
}
}
5 changes: 5 additions & 0 deletions tests/cases/javascript/edits-in-place/new-d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class R {
async fresh(x) {
return x + 1;
}
}
26 changes: 26 additions & 0 deletions tests/cases/javascript/edits-in-place/new-default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export class S {
constructor({ a, b }) {
this.a = a;
this.b = b;
this.n = 1;
}

async oldName(x, y) {
return x + y;
}

keep(v) {
return v;
}
}

export function stamp(v, clock = { millis: () => Date.now() + 1 }) {
return { v, at: clock.millis() };
}

export class Err extends Error {
constructor(msg) {
super(msg);
this.name = 'Err';
}
}
26 changes: 26 additions & 0 deletions tests/cases/javascript/edits-in-place/new-destructure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export class S {
constructor({ a, b, c }) {
this.a = a;
this.b = b;
this.n = 1;
}

async oldName(x, y) {
return x + y;
}

keep(v) {
return v;
}
}

export function stamp(v, clock = { millis: () => Date.now() }) {
return { v, at: clock.millis() };
}

export class Err extends Error {
constructor(msg) {
super(msg);
this.name = 'Err';
}
}
27 changes: 27 additions & 0 deletions tests/cases/javascript/edits-in-place/new-errbody.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export class S {
constructor({ a, b }) {
this.a = a;
this.b = b;
this.n = 1;
}

async oldName(x, y) {
return x + y;
}

keep(v) {
return v;
}
}

export function stamp(v, clock = { millis: () => Date.now() }) {
return { v, at: clock.millis() };
}

export class Err extends Error {
constructor(msg) {
super(msg);
this.code = 7;
this.name = 'Err';
}
}
Loading
Loading