Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning de super incorrecto #305

Open
lspigariol opened this issue Nov 4, 2024 · 1 comment · May be fixed by #318
Open

Warning de super incorrecto #305

lspigariol opened this issue Nov 4, 2024 · 1 comment · May be fixed by #318
Labels
component: validator Linter / Validator good first issue Good for newcomers priority: medium A "should" issue, whenever we have the time to solve it

Comments

@lspigariol
Copy link

lspigariol commented Nov 4, 2024

Hay casos donde equivocadamente se da un warning de que no se debe usar solo super() en un metodo

ShoudNotOnlyCallToSuper

class Cohete  {
  var property combustible = 100
  method andar() {
    combustible -= 10
  } 
}

class CoheteAcelerado inherits Cohete {
  override method andar() {
    super() 
    super()
  } 
}

image

@lspigariol lspigariol changed the title Los warnings de super no son correctos Warning de super incorrecto Nov 4, 2024
@fdodino fdodino added good first issue Good for newcomers component: validator Linter / Validator labels Nov 9, 2024
@fdodino
Copy link
Contributor

fdodino commented Nov 9, 2024

El validador está preguntando

export const shouldNotOnlyCallToSuper = warning<Method>(node => {
  const callsSuperWithSameArgs = (sentence?: Sentence) => sentence?.is(Super) && sentence.args.every((arg, index) => arg.is(Reference) && arg.target === node.parameters[index])
  return isEmpty(node.sentences) || !node.sentences.every(sentence =>
    callsSuperWithSameArgs(sentence) || sentence.is(Return) && callsSuperWithSameArgs(sentence.value)
  )
}, undefined, sourceMapForBody)

habría que pedir además que node.sentences tenga longitud 1.

@fdodino fdodino added the priority: medium A "should" issue, whenever we have the time to solve it label Nov 9, 2024
@MEUFAJ MEUFAJ linked a pull request Nov 30, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: validator Linter / Validator good first issue Good for newcomers priority: medium A "should" issue, whenever we have the time to solve it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants