Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • This issue is fixed

  • the most human readable solutions always is better

  • Hey!!! You stole that Kata name from my series of FIXME: Kata.

    :-(

    How about coming up with your own name instead?

    Thanks.

    DM

  • Okay, thank you

  • if (/Math\.pow/.test(usercode))

    This is highly not recommended because I can do this:

    var m = "pow"
    var f = Math[m]
    
    // I can even use Unicode escape characters or other methods to obfuscate m even further
    

    You can disable Math.pow by rewriting it in preloaded section:

    Math.pow = undefined
    
    //or
    
    Math.pow = ()=>throw new Error('Math.pow is disabled')
    
  • I changed the tests to random ones, however I do not quite understand how Preloaded works. Can I insert this code in Preloaded?

      const usercode = require('fs').readFileSync('/home/codewarrior/solution.txt', 'utf8');  
    	if (/Math\.pow/.test(usercode)) {
    		throw new SyntaxError("You can't use Math.pow()");
    	} else if (/\*\*/.test(usercode)) {
    		throw new SyntaxError("You can't use ** ");
    	}
    
  • This comment is hidden because it contains spoiler information about the solution

  • That code was somewhat viable, in my opinion. I tried to find the previous version, but I can't even get it out of Revisions.

    Please don't fall into the trap of measuring everything by your opinion.

  • Yes. My point, however, is that if a bugfix kata gives an initial code too far away from something actually viable, it stops being a bugfix since you're pretty much rewriting the whole thing in the end anyway.

  • A bug might cause any behaviour, including "just plain not working". A syntax error is (one sort of) a bug, right?

  • Well, at least I'm pretty sure that according to our common usage of "bugs" and "bugfix", it doesn't mean "salvaging code that just plain won't work once you try to run it". That's called a totally broken program.

  • Math.pow can be simply disabled in Preloaded, unfortunately, with **, this is impossible, and you will have to resort to checking the user code in the above way.

    Do not rely on looking at pow.toString(), because that is all too easily "fixed" by the cheating user. Also, with const pow=Math.pow;, I don't even need to "fix" it.

  • The initial code did not seem that wrong to me. It may not have been worth salvaging, but it could be done.

    And not conforming to your idea of a bugfixing kata is an issue? Do you have a reference for that?

  • The huge mess of initial code basically means it's not a bugfix kata; the original code is so wrong you're going to just rewrite the whole thing anyway.

    I've said this many times, but one does not simply make a bugfix kata. Bugfix kata is not about rewriting "code" that blatantly doesn't even work/compile, or is in an alien syntax (yes, there are lots of these bugfix katas). It's about finding actual bugs in seemingly conformant code. There are lots of existing bugfix katas that suffers from the same problem, and I often wish I can unpublish all of them because they're just that boring.

    In other words, this kata is very uninspiring.

  • Loading more items...