This may or may not help.
https://bitbucket.org/atlassianlabs/stash-filesize-hook-plugin/
And you may also require the ContentService:
https://developer.atlassian.com/static/javadoc/stash/latest/api/reference/com/atlassian/stash/content/ContentService.html
That said I would strongly advise you not to run PMD (or things like that) in a pre-receive hook. While convenient, it's going to make your pushes to Stash extremely slow. Instead, my advice would be to restrict pushes to master, and run branch builds across your PRs. The builds can run PMD and whatever other code checks you like, pushing the results back to Stash when they're done. Stash also has a setting that requires PRs have at least one green build.
Again, you may want to consider heading over to Answers as that has a bigger community built around Atlassian questions.