Skip to content

Commit

Permalink
fix lints & limpieza
Browse files Browse the repository at this point in the history
  • Loading branch information
user committed Jun 18, 2024
1 parent 78c4137 commit 6efb5c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ src/wre/wre.json
coverage
.DS_Store
/public/diagram/lib/*
wollok.log
wollok.log
log/*
25 changes: 6 additions & 19 deletions src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default async function (programFQN: Name, options: Options): Promise<void


const ioGame: Server | undefined = initializeGameClient(options)
const interpreter = game ? getGameInterpreter(environment) : interpret(environment, { ...natives })
const interpreter = interpret(environment, { ...natives })
const programPackage = environment.getNodeByFQN<Package>(programFQN).parent as Package
const dynamicDiagramClient = await initializeDynamicDiagram(programPackage, options, interpreter)

Expand All @@ -81,13 +81,6 @@ export default async function (programFQN: Name, options: Options): Promise<void
}
}

// TODO: ver si se elimina este método
export const getGameInterpreter = (environment: Environment): Interpreter => {
const interpreter = interpret(environment, natives)

return interpreter
}

export const initializeGameClient = ({ project, assets, host, port, game }: Options): Server | undefined => {
if (!game) return undefined

Expand Down Expand Up @@ -185,7 +178,7 @@ export const eventsFor = (io: Server, interpreter: Interpreter, dynamicDiagramCl

const id = setInterval(() => {
try {
const tsStart = performance.now()
const tsStart = performance.now()
interpreter.send('flushEvents', gameSingleton, interpreter.reify(timer))

draw(interpreter, io)
Expand All @@ -201,9 +194,9 @@ export const eventsFor = (io: Server, interpreter: Interpreter, dynamicDiagramCl
// cada 30 muestras se imprime por consola el tiempo promedio
// que tardó en procesar todos los eventos
if(muestras >= 30) {
logger.debug(`flushEvents: ${(tEvents / muestras).toFixed(2)} ms`)
muestras = 0
tEvents = 0
logger.debug(`flushEvents: ${(tEvents / muestras).toFixed(2)} ms`)
muestras = 0
tEvents = 0
}

// We could pass the interpreter but a program does not change it
Expand Down Expand Up @@ -265,9 +258,6 @@ export const getAssetsFolder = ({ game, project, assets }: Options): string => {

export const buildEnvironmentForProgram = async ({ project, skipValidations, game }: Options): Promise<Environment> => {

Check warning on line 259 in src/commands/run.ts

View workflow job for this annotation

GitHub Actions / test

'game' is defined but never used. Allowed unused args must match /^_/u
let environment = await buildEnvironmentForProject(project)

Check failure on line 260 in src/commands/run.ts

View workflow job for this annotation

GitHub Actions / test

'environment' is never reassigned. Use 'const' instead
if (game) {
environment = link([drawDefinition()], environment)
}
validateEnvironment(environment, skipValidations)
return environment
}
Expand All @@ -279,9 +269,6 @@ export const gameHost = (host: string): string => host ?? DEFAULT_HOST

export const dynamicDiagramPort = (port: string): string => `${+gamePort(port) + 1}`

const drawDefinition = () => parse.File('draw.wlk').tryParse('object drawer{ method apply() native }')


const draw = (interpreter: Interpreter, io: Server) => {
const game = interpreter?.object(GAME_MODULE)
try {
Expand All @@ -304,4 +291,4 @@ const draw = (interpreter: Interpreter, io: Server) => {
if (debug) logger.error(error)
interpreter.send('stop', game)
}
}
}

0 comments on commit 6efb5c2

Please sign in to comment.