Kesha seems stuck between a rock and a hard place on “Rainbow,” her third album and her first since the ongoing legal turmoil and startling allegations between the singer and her former producer/mentor, Dr. Luke began nearly three years ago. She rose to fame essentially as a gifted musical comedienne with her wildly entertaining debut, “Animal,” seven years ago, but it would strike an odd note for her to return after the years of legal trauma with an album of party anthems like her biggest hit, “Tik Tok.” But does the world want a Kesha who’s traded in irreverence for righteousness?

She splits the difference on “Rainbow,” which is initially so front-loaded with angry ballads, pop sing-alongs, and feisty feminist anthems that you might wonder if any real sense of fun got dropped along with the dollar sign in her name. The old mirth does reappear, mostly in the album’s second half. But first, she’s got some things to get off her chest, and some war paint to put on.

For a while, anyway, it seems that a better title for this album than “Rainbow” would have been “Warrior” (except she used that one on her previous record). It would be nice to report that the songs addressing the distress of the last few years reveal her as a great confessional singer/songwriter, but the clunkiness of her most sober material here blunts its impact. Her most angry/inspirational tracks, like “Don’t Let the Bastards Get You Down,” “Learn to Let Go,” and “Praying,” suffer not from seriousness but relative artlessness as Kesha unleashes a stream of Deepak-ian self-help bromides (embellished with plenty of Tupac-ian language) that’d sound better as bathroom-mirror sticky-note affirmations than they do as gospel-choir-backed lyrics.

Aspirationally, it feels like she’s trying to go for Pink at her pissed-off best, or the Dixie Chicks in “Not Ready to Make Nice” mode, but either of those acts would have tossed first-draft lines like “I’ve found a strength I’ve never known” and “Don’t let the losers take your magic.” (At least “I’ve decided all the haters everywhere can suck my dick” is too profane to quite count as prosaic.) The moment for some kind of personal revelation is nigh, but all these pop-psych clichés leave you feeling you know less about the real Kesha than you did coming in.

It’s no judgment on the gravity of her situation to say that that the album starts to feel more accomplished as its subject matter gets more trivial. The levity reaches a peak in “Hunt You Down,” a country-music pastiche that veers close to outright genre parody yet still has the album’s most irresistible hook. (It’s definitely the least Lana Del Rey-like song that producer Rick Nowels has ever been involved with; you might wish he’d worked on more than just one track here.) There’s a less goofy take on C&W in Kesha’s duet with Dolly Parton on an earnest remake of the latter’s “Old Flames (Can’t Hold a Candle to You),” as penned a good 40 years ago by Kesha’s Music-Row-pro mom, Pebe Sebert (who also contributed to some of the new material).

The agreeable musical extremes of “Rainbow” are represented by the ornate title track, produced by Ben Folds in his most cheerfully paisley, orchestral mode, and “Boogie Feet,” the second and by far the silliest of two new collaborations with the rock band Eagles of Death Metal. Throwing the album’s last traces of sober self-actualization to the wind, “Boogie Feet” has her declaring: “There’s no wrong, there’s no right/ Koo Koo bananas unite.” The return to Kesha Mach 1 ridiculousness feels refreshing and, just maybe, even more authentic. Not that you’d want her to push past her pain prematurely, but when it comes to the writing part, Kesha just happens to still be cleverer at playing koo-koo than guru.

Executive producer: Kesha
Producers: Ricky Reed, Drew Pearson, Stuart Crichton, Brody Brown, Jonny Price, Ryan Lewis, Ben Folds, Rick Nowels, Pepe Sebert