There were some dark clouds over J.C. Penney at one time, but the looks like bright sunshine and blue skies for the retailer today.

They say there's nothing so powerful as an idea whose time has come, and at least on Wall Street, it appears the idea that J.C. Penney's (JCPN.Q) comeback is real has finally taken hold.

In recent weeks the department store operator has received a credit upgrade from Standard & Poor's, which raised the rating on its debt from CCC+ to B with a chance of future upgrades to come, and the Financial Times reports that over the past year the number of analysts covering the retailer and having a sell recommendation on its stock dropped from 44% to just 15%.

After years of believing the retailer was poised to go south, Wall Street is now coming around to the notion that it's time to buy J.C. Penney's stock. Should investors listen?

While there were some very good reasons for Wall Street's pessimism -- at one point it did seem to be a coin toss away from declaring bankruptcy -- the stampede to the buy side comes after J.C. Penney has repeatedly surprised them with better-than-expected results. Although it may be tempting to view this as something akin to a contrarian indicator, in this instance I think Wall Street's finally got it right.

The bear case against the retailer would point to J.C. Penney's recent success as being predicated on having gone up against very easy comparables. The business had gotten so bad that any gain looks better than it really is. While it has seemingly stabilized the hemorrhaging it suffered, the presence of more financially sound competitors such as Wal-Mart and Target on the discount side and Internet juggernaut Amazon.com (AMZN 1.30%) on the digital side foretell future pain.

The era of the department store is in its twilight. Its model hasn't really changed in the past 150 years, since Harry Gordon Selfridge managed the early Marshall Fields stores. They can provide consumers with a broad mix of goods, but the inventory will never be as deep as what can be found online.

J.C. Penney has done a good job of figuring out the styles its customers want, which has led it to steal market share from rivals.

Although bricks-and-mortar stores still account for the vast bulk of all retail sales, there is little doubt that online sales can no longer be ignored. Just this past Christmas, for example, store traffic tumbled hard while online sales soared, and most of those consumers went to Amazon. The market analysts at Slice Intelligence say the e-commerce leader generated 42% of all sales made online. To put that in perspective, the next 10 biggest retailers (including Apple, Best Buy, and Wal-Mart) combined for less than 25% of the total. In fact, second place Best Buy notched a meager 4.3% share of total e-commerce sales.

Moreover, they say CEO Marvin Ellison has been slashing costs too deep. While sales were up 3% in fiscal 2015, J.C. Penney slashed SG&A expenses by 5.5%. Cutting out the fluff can only go so far, and too deep of a cut can impair a company's ability to grow.

Gloomy, indeed, but not the whole story. First, J.C. Penney did need to stabilize the loss of customers it experienced, but what its results show is that not only has it won back those who fled during the downturn, but now it's winning over customers from rivals Kohl's (KSS 2.83%) and Macy's (M 1.44%). The former's sales were essentially flat all of last year (and it's even toyed with the idea of going private), while the latter saw net sales drop nearly 4% and comparable sales fall 2.5%, including those its licenses.

And Ellison's cutbacks are a smart realignment of the retailer's costs with its new, reduced operations. It's closed several dozen stores over the past few years, and announced in January it would be closing seven more this month. It still has over 1,000 stores, but the retailer is focusing on a smaller footprint now, one that again anticipates profitability but has already achieved the status of becoming free cash flow positive once more. It ended 2015 with $131 million in free cash flow, and its liquidity has improve1d while it's also paid down its debt.

Sure, the easy gains have been made, but thus far there is nothing to suggest that J.C. Penney's path is not still one filled with growth and expansion This is one late call by Wall Street that it is getting right.