0

I have a repository with Codacy incorporated to check the quality of my code. When trying to do a commit I'm getting these two errors that I don't know how to fix... any help?

Expected property shorthand.

in this line: this.state.notifications.push({name: name, url: inboxFolder.files[parseInt(index)].url});

Found fs.readFile with non literal argument at index 0

in this line: let fol = await this.fc.readFile(url.toString());

Lucia
  • 1

2 Answers2

2

The first error can be solved with the following code lines:

let url = inboxFolder.files[parseInt(index)].url;
this.state.notifications.push({name, url});
Dan
  • 1,238
  • 2
  • 17
  • 32
sgb
  • 21
  • 1
1

Codacy is recommending to use 2 good practices on javascript language

  1. Use property shorthand syntax (https://alligator.io/js/object-property-shorthand-es6/)
let url = inboxFolder.files[parseInt(index)].url;
this.state.notifications.push({name, url});
  1. there may be something on the context / surrounding lines, but it seems to recomment not using a variable as file to read. this is probably because it may be user input, and it's not validated, hence it may bring security problems
pedrorijo91
  • 7,635
  • 9
  • 44
  • 82