Indefinite integral $\int \frac{1}{2-\cos(x)}\,dx$ has discontinuities. How to fix? Using the standard tangent half-angle substitution, we get $$\int \frac{1}{2-\cos(x)}\,dx = \frac{2}{\sqrt{3}}\tan^{-1}(\sqrt{3}\tan\frac{x}{2}) + C$$
The resulting antiderivatives are piecewise continuous functions with discontinuities at $x = (2k+1)\pi$. However, the integrand is continuous everywhere, so any antiderivative must be continuous everywhere (??) according to FTC. So, how do we deal with this problem? What is the correct form of the antiderivatives? Is there a form that avoids the discontinuities?
 A: Your problem is the $+C$ term. Take for example $\frac{1}{x}$. Its most general antiderivative is usually given as
$$\int \frac{1}{x}dx = \ln|x| + C$$
But this is not correct. Notice that the piecewise function 
$$f(x)=\begin{cases} \ln(-x) +2 & x < 0\\ \ln(x) -1 & x> 0\\ \end{cases}$$
is also an antiderivative of $\frac{1}{x}$, even thought the $+C$'s on both sides were different. So any time your integrand has a singularity, the integration constant is allowed to change when you cross it.
On the domain when you integrated, the $+C$ are only uniform between the discontinuities. Otherwise, each discontinuous piece must have its own $+C$. And one can choose a series of $+C$'s such that the resultant antiderivative is continuous.

$\mathbf{EDIT}$: In this case, the continuous antiderivative should be of the form:
$$\frac{2}{\sqrt{3}}\tan^{-1}\left(\sqrt{3}\tan\left(\frac{x}{2}\right)\right) + \frac{2\pi}{\sqrt{3}}\Bigr\lfloor \frac{1}{2\pi}x+\frac{1}{2}\Bigr\rfloor + C$$
This function is both continuous and differentiable at its former discontinuities, even though it may not look like it at first glance.
And a graph of the fixed function, courtesy of Desmos:

A: Although I'm really late with the answer, here's something other people might find interesting.
There is a continous elementary antiderivative,
$$F(x)=\frac{2}{\sqrt{3}}\left(\frac{x}{2}+ \tan^{-1}\left(\frac{\left( \sqrt{3}-1 \right)\tan\frac{x}{2}}{1+\sqrt{3}\tan^2\frac{x}{2}}\right)\right)$$
— but finding it may be somewhat inconvenient. Here's the how.
First of all, we carefully look at the function $\tan^{-1}\left(\tan x\right)$. Quite interesting plot, isn't it?
So, we see (check it!) that the floor function can be written as $$\mathbb{floor}(x)=\frac{2x-1}{2}-\frac{1}{\pi} \tan^{-1}\left(\tan\left( \frac{2x-1}{2}\pi  \right)\right)$$
Next, we find the precise floor expression that eliminates the discontinuities in your antiderivative. That part of the work is already done in one of the answers, $$\left \lfloor \frac{1}{2}\left( \frac{x}{\pi}+1 \right)  \right \rfloor = \frac{1}{\pi}\left( \frac{x}{2}-\tan^{-1}(\tan(\frac{x}{2}))\right) $$
Then you add this staircase function to your antiderivative, and end up with
$$F(x)=\frac{2}{\sqrt{3}} \left[ \tan^{-1}\left(\sqrt{3}\tan\frac{x}{2}\right)+\frac{x}{2}-\tan^{-1}\left(\tan\frac{x}{2}\right)  \right] $$ which is already cool if you don't mind stuff like $\tan^{-1}(\tan(x))$. But since we can combine inverse tangent sums by using the formula $\tan^{-1}(a)+\tan^{-1}(b)=\tan^{-1} \left( \frac{a+b}{1-ab} \right)$, we can go even further!
Combining inverse tangents and simplifying the resulting expression, we finally get a fully continuous antiderivative $F$ that we can use to calculate definite integrals without paying attention to the limits.
A: Suppose you want to it from $x=0$ to $2\pi$ using $\tan(x/2)=t$. A transformation $t(x)$ needs to be continuous and monotonic (without max/min). But $(x)=\tan(x/2)$ is discontinuous at $x=\pi$, so it is a bad substitution. A bad substitution can be made to work but breaking the domain of integration at the discontinuities. 
One way is 
$$I=\int_{0}^{2\pi} \frac{dx}{2-\cos x}= \int_{0^+}^{\pi^-}\frac{dx}{2-\cos x} +\int_{\pi^+}^{2\pi^-}\frac{dx}{2-\cos x}.$$ This way $\tan(x/2)|_{x=\pi^-}=+ \infty$ and $\tan(x/2)|_{\pi^+}=-\infty.$ So you get
$$I=\frac{2}{\sqrt{3}}[(\frac{\pi}{2}-0)+(0- \frac{-\pi}{2})]=\frac{2\pi}{\sqrt{3}}.$$
Else, the other way is
You may directly use the domain reduction by 
$$\int_{0}^{2a} f(x) dx=2\int_{0}^{a} f(x) dx, ~if~ f(2a-x)=f(x).$$
You get $$I=2\int_{0}^{\pi^-} \frac{dx}{2-\cos x}.$$
