<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Raphael Carvalho on Medium]]></title>
        <description><![CDATA[Stories by Raphael Carvalho on Medium]]></description>
        <link>https://medium.com/@raphaelbluteau?source=rss-7dcb25f84b14------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Xt9XnL67YCTm-wE8lQu01g.jpeg</url>
            <title>Stories by Raphael Carvalho on Medium</title>
            <link>https://medium.com/@raphaelbluteau?source=rss-7dcb25f84b14------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 03:50:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@raphaelbluteau/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Aplicando code style em projetos Java com Checkstyle]]></title>
            <link>https://medium.com/@raphaelbluteau/aplicando-code-style-em-projetos-java-com-checkstyle-e091908657d6?source=rss-7dcb25f84b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/e091908657d6</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[code-style]]></category>
            <dc:creator><![CDATA[Raphael Carvalho]]></dc:creator>
            <pubDate>Sun, 03 Jun 2018 12:35:00 GMT</pubDate>
            <atom:updated>2018-06-03T12:35:00.011Z</atom:updated>
            <content:encoded><![CDATA[<p>Em projetos com mais de um desenvolvedor é fácil ver as diferenças de estilo em que cada um programa, deixando o codebase não uniforme. Dois ou quatro espaços na indentação? Espaços ou tabulação? Espaço entre o <em>if</em> e o parênteses? Já vi discussões ferrenhas sobre isso, claro que não no nível da série Silicon Valley (<em>ver episódio S03E06</em>).</p><h3>Qual a importância de aplicar code style?</h3><p>A maior parte do tempo de vida de um software não é no desenvolvimento, mas em manutenção, como correção de bugs e melhorias. Outro fato importante é que dificilmente quem desenvolveu o software ficará responsável por sua manutenção durante todo o tempo que ele estiver em operação. Quanto mais fácil de ler e compreender seu código, menos tempo um desenvolvedor levará para conseguir se integrar à equipe.</p><p>Portanto aplicar o code style é uma ação simples que reduz o &quot;atrito&quot; e contribui muito para a saúde do projeto.</p><h3>Qual code style utilizar?</h3><p>Esta é uma decisão que você deve tomar com o seu time, mas há dois estilos que sugiro para começar: da Sun ou da Google.</p><p>Minha sugestão é que você escolha um desses dois estilos já que são suportados pela biblioteca <a href="http://checkstyle.sourceforge.net/">Checkstyle</a>, que é uma ferramenta que auxilia a manter padrões de code style em projetos Java. Se me permite um pitaco: avalie com carinho a possibilidade de adotar o code style da Google, que vem sendo atualizado conforme a linguagem Java avança e conforme convenções de estilo são adotadas(o da Sun por outro lado traz os padrões definidos em 1999).</p><h3>Configurando o Checkstyle</h3><p>Para facilitar, vamos configurar o Checkstyle em um projeto existente, aquele que criamos no artigo da semana passada, o <a href="https://medium.com/@raphaelbluteau/spring-boot-swagger-documentando-sua-api-automaticamente-27903293aeb6">Spring Boot + Swagger: documentando sua API automaticamente</a>. Baixe o projeto disponível <a href="https://github.com/raphaelbluteau/swagger-ready-spring-boot">neste repositório do Github</a>.</p><p>Primeiramente, baixe o arquivo de configuração do Checkstyle diretamente de seu repositório. No nosso caso vamos baixar o referente ao code style da Google <a href="https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml">disponível neste link</a>. Salve o arquivo de forma que seu caminho fique <em>config/checkstyle/google_checks.xml.</em></p><p>Abra o build.gradle e insira o código abaixo:</p><pre>apply <strong>plugin</strong>: <strong>&#39;checkstyle&#39;<br><br></strong>checkstyle {<br>    toolVersion = <strong>&#39;8.10.1&#39;<br>    </strong>configFile = rootProject.file(<strong>&#39;config/checkstyle/google_checks.xml&#39;</strong>)<br>    sourceSets = [sourceSets.main]<br>    configProperties = [<br>            <strong>&#39;configDir&#39;</strong>: rootProject.file(<strong>&#39;config/checkstyle&#39;</strong>),<br>            <strong>&#39;baseDir&#39;</strong>: rootDir,<br>    ]<br>    showViolations = <strong>true<br>    </strong>ignoreFailures = <strong>true<br></strong>}<br><br>checkstyleTest {<br>    enabled = <strong>false<br></strong>}</pre><p>Nosso build.gradle final:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PSXoG8bSQMAcbna9WShtvg.png" /></figure><p>Veja que na configuração do Checkstyle temos um ignoreFailures configurado com true. Eu recomendo esta configuração ao menos durante a fase de ajuste do projeto ao code style, já que sem ela a build irá falhar caso haja alguma violação de code style. Com esta configuração, warnings serão exibidos no log e um relatório será criado, para que você possa ver o que precisa ser ajustado.</p><p>Falando em relatório, vamos configurá-lo:</p><pre>tasks.withType(Checkstyle) {<br>    reports {<br>        html.destination rootProject.file(<strong>&quot;build/reports/checkstyle.html&quot;</strong>)<br>    }<br>}</pre><p>Faça agora uma build (gradle build) e verifique o relatório em <em>build/reports/checkstyle </em>. Para facilitar, o plugin checkstyle adicionou uma task permitindo que você cheque o status do projeto executando: <em>gradle checkstyleMain</em>.</p><p>Para entender as violações de code style e como resolvê-las, leia a <a href="http://checkstyle.sourceforge.net/checks.html">documentação oficial do Checkstyle</a>.</p><h3>Autoformatando o código</h3><p>Estão disponíveis arquivos XML que configuram a IDE para formatar o código automaticamente, resolvendo a maioria das violações de code style. <a href="https://github.com/HPI-Information-Systems/Metanome/wiki/Installing-the-google-styleguide-settings-in-intellij-and-eclipse">Siga essas instruções</a> e peça que seus colegas façam o mesmo caso tenham escolhido o code style da Google. Para o da Sun o processo é o mesmo, bastando substituir pelo arquivo correto.</p><p>Por hoje é isso. Fique à vontade para comentar, estou também disponível caso tenha alguma dúvida.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e091908657d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring Boot + Swagger: documentando sua API automaticamente]]></title>
            <link>https://medium.com/@raphaelbluteau/spring-boot-swagger-documentando-sua-api-automaticamente-27903293aeb6?source=rss-7dcb25f84b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/27903293aeb6</guid>
            <category><![CDATA[swagger]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[api-documentation]]></category>
            <dc:creator><![CDATA[Raphael Carvalho]]></dc:creator>
            <pubDate>Sun, 27 May 2018 13:41:08 GMT</pubDate>
            <atom:updated>2020-08-08T23:32:40.353Z</atom:updated>
            <content:encoded><![CDATA[<p>Quem já desenvolveu APIs sabe o quanto é importante que quem as consuma saiba do que se trata e quais os contratos que são firmados no envio e no recebimento de dados. O <a href="https://swagger.io/">Swagger</a> é uma das ferramentas mais importantes que visa solucionar esse problema de documentação e outros (que serão tema de futuros artigos que escreverei).</p><p>Esta semana iremos criar um projeto simples em <a href="https://projects.spring.io/spring-boot/">Spring Boot</a> que documenta automaticamente o Swagger utilizando uma biblioteca chamada <a href="https://github.com/springfox/springfox">SpringFox</a>. Caso queira já pular para o projeto completo, ele está <a href="https://github.com/raphaelbluteau/swagger-ready-spring-boot">disponível neste repositório no Github</a>.</p><p>Como pré-requisito para acompanhar esse tutorial você precisa ter um conhecimento intermediário na linguagem Java e ao menos básico no framework Spring Boot. Recomendo começar pelos guias disponíveis no site <a href="https://spring.io/guides">spring.io</a>.</p><h3>1. Inicializando o projeto</h3><p>Vamos utilizar o <a href="https://start.spring.io/">Spring Initializr</a>, a melhor maneira de iniciar um projeto Spring. Acesse e escolha Gradle ao invés de Maven, mas caso seu projeto utilize Maven, não se preocupe, basta baixar o projeto completo ao final do artigo, eu criei um pom.xml também.</p><p>Nas dependências, insira apenas Web e Lombok e gere o projeto, importando em sua IDE (eu utilizo Intellij IDEA). Caso não conheça o <a href="https://projectlombok.org/">Lombok</a>, sugiro que dê uma olhada e adote em seus projetos.</p><h3>2. Configurando o Swagger</h3><p>Após importar o projeto, abra o build.gradle e insira em dependencies as dependências necessárias para o Swagger (ocultei no exemplo as dependências que já vem configuradas pelo Initializr):</p><pre>dependencies {<br>    compile(<strong>&#39;io.springfox:springfox-swagger2:2.9.2&#39;</strong>)<br>    compile(<strong>&#39;io.springfox:springfox-swagger-ui:2.9.2&#39;</strong>)<br>}</pre><p>Em seguida é preciso configurar o Swagger em seu projeto. Crie uma classe chamada SwaggerConfig e nela insira esse conteúdo:</p><pre><strong>package </strong>com.example.swaggerready;</pre><pre><strong>import </strong>org.springframework.context.annotation.Bean;<br><strong>import </strong>org.springframework.context.annotation.Configuration;<br><strong>import </strong>org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;<br><strong>import </strong>org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;<br><strong>import </strong>springfox.documentation.builders.ApiInfoBuilder;<br><strong>import </strong>springfox.documentation.builders.RequestHandlerSelectors;<br><strong>import </strong>springfox.documentation.service.ApiInfo;<br><strong>import </strong>springfox.documentation.spi.DocumentationType;<br><strong>import </strong>springfox.documentation.spring.web.plugins.Docket;<br><strong>import </strong>springfox.documentation.swagger2.annotations.EnableSwagger2;<br><br>@Configuration<br>@EnableSwagger2<br><strong>public class </strong>SwaggerConfig <strong>extends </strong>WebMvcConfigurationSupport {<br><br>  @Bean<br>  <strong>public </strong>Docket greetingApi() {<br>    <strong>return new </strong>Docket(DocumentationType.<strong><em>SWAGGER_2</em></strong>)<br>        .select()<br>        .apis(RequestHandlerSelectors.<em>basePackage</em>(<strong>&quot;com.example.swaggerready&quot;</strong>))<br>        .build()<br>        .apiInfo(metaData());<br><br>  }<br><br>  <strong>private </strong>ApiInfo metaData() {<br>    <strong>return new </strong>ApiInfoBuilder()<br>        .title(<strong>&quot;Spring Boot REST API&quot;</strong>)<br>        .description(<strong>&quot;\&quot;Spring Boot REST API for greeting people\&quot;&quot;</strong>)<br>        .version(<strong>&quot;1.0.0&quot;</strong>)<br>        .license(<strong>&quot;Apache License Version 2.0&quot;</strong>)<br>        .licenseUrl(<strong>&quot;https://www.apache.org/licenses/LICENSE-2.0\&quot;&quot;</strong>)<br>        .build();<br>  }<br><br>  @Override<br>  <strong>protected void </strong>addResourceHandlers(ResourceHandlerRegistry registry) {<br>    registry.addResourceHandler(<strong>&quot;swagger-ui.html&quot;</strong>)<br>        .addResourceLocations(<strong>&quot;classpath:/META-INF/resources/&quot;</strong>);<br><br>    registry.addResourceHandler(<strong>&quot;/webjars/**&quot;</strong>)<br>        .addResourceLocations(<strong>&quot;classpath:/META-INF/resources/webjars/&quot;</strong>);<br>  }<br>}</pre><p>Veja que criamos um Bean, não se esqueça de alterar o basePackage para o utilizado em seu projeto (o meu no caso é <em>com.example.swaggerready</em>), e é com base nele que o Swagger irá encontrar seus endpoints para documentar.</p><h3>3. Vamos ao que interessa</h3><p>Primeiramente vamos criar no package <em>hello</em> a classe Greeting, que irá representar nossa saudação:</p><pre><strong>package </strong>com.example.swaggerready.hello;</pre><pre><strong>import </strong>lombok.AllArgsConstructor;<br><strong>import </strong>lombok.Data;<br><strong>import </strong>lombok.NoArgsConstructor;<br><br>@Data<br>@AllArgsConstructor<br>@NoArgsConstructor<br><strong>public class </strong>Greeting {<br><br>  <strong>private </strong>String <strong>message</strong>;<br>}</pre><p>Veja que utilizamos anotações do Lombok que dispensam a necessidade de criarmos os construtores e getters/setters.</p><p>Agora vamos finalmente ao nosso Controller:</p><pre><strong>package </strong>com.example.swaggerready.hello;<br><br><strong>import </strong>io.swagger.annotations.Api;<br><strong>import </strong>io.swagger.annotations.ApiOperation;<br><strong>import </strong>org.springframework.http.MediaType;<br><strong>import </strong>org.springframework.web.bind.annotation.GetMapping;<br><strong>import </strong>org.springframework.web.bind.annotation.PathVariable;<br><strong>import </strong>org.springframework.web.bind.annotation.RequestParam;<br><strong>import </strong>org.springframework.web.bind.annotation.RestController;<br><br>@RestController<br>@Api(value = <strong>&quot;Greeting&quot;</strong>)<br><strong>public class </strong>GreetingController {<br><br>  @ApiOperation(value = <strong>&quot;Greets the world or Niteroi&quot;</strong>)<br>  @GetMapping(value = <strong>&quot;/hello&quot;</strong>, produces = MediaType.<strong><em>APPLICATION_JSON_UTF8_VALUE</em></strong>)<br>  <strong>public </strong>Greeting hello(@RequestParam(required = <strong>false</strong>) <strong>boolean </strong>niteroi) {<br>    Greeting greeting = <strong>new </strong>Greeting(<strong>&quot;Hello world&quot;</strong>);<br>    <strong>if </strong>(niteroi) {<br>      greeting.setMessage(greeting.getMessage().replace(<strong>&quot;world&quot;</strong>, <strong>&quot;Niteroi&quot;</strong>));<br>    }<br>    <strong>return </strong>greeting;<br>  }<br><br>  @ApiOperation(value = <strong>&quot;Greets a person given her name&quot;</strong>)<br>  @GetMapping(value = <strong>&quot;/hello/{name}&quot;</strong>, produces = MediaType.<strong><em>APPLICATION_JSON_UTF8_VALUE</em></strong>)<br>  <strong>public </strong>Greeting get(@PathVariable String name) {<br>    <strong>return new </strong>Greeting(<strong>&quot;Hello, &quot; </strong>+ name);<br>  }<br>}</pre><p>A primeira anotação do Swagger que utilizamos é a @Api, onde no nosso exemplo declaramos do que se trata nossa API. Veja que ela é utilizada uma vez no Controller. A outra anotação utilizada é a @ApiOperation, para cada endpoint, declarando do que se trata a operação. Vamos agora fazer a build e rodar a aplicação, e o processo irá disponibilizar o Swagger na URL <a href="http://localhost:8080/swagger-ui.html">http://localhost:8080/swagger-ui.html</a> (a porta padrão é 8080, mas no seu projeto pode ter sido configurada para outra porta, verifique no log ao inicializar).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pKHEvDlY98-8QUMr6B6Z8g.png" /><figcaption>Com pouca configuração e duas anotações no Controller conseguimos este resultado.</figcaption></figure><p>Você pode interagir no Swagger UI e testar facilmente o Controller que criamos. Leia mais sobre o Springfox para aprender como alcançar resultados mais avançados em <a href="https://github.com/springfox/springfox">https://github.com/springfox/springfox</a> .</p><p>Isso é tudo por enquanto, fique à vontade para deixar seu comentário.</p><p>Relembrando, o projeto utilizado no tutorial está disponível em <a href="https://github.com/raphaelbluteau/swagger-ready-spring-boot">https://github.com/raphaelbluteau/swagger-ready-spring-boot</a> .</p><p>Você pode me acompanhar no meu blog: <a href="https://raphaelcarvalho.dev/">https://raphaelcarvalho.dev</a> .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27903293aeb6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fixing “command ‘gcc’ failed with exit status 1” while installing Pillow]]></title>
            <link>https://medium.com/@raphaelbluteau/fixing-command-gcc-failed-with-exit-status-1-while-installing-pillow-48f9b9f71726?source=rss-7dcb25f84b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/48f9b9f71726</guid>
            <category><![CDATA[fedora]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Raphael Carvalho]]></dc:creator>
            <pubDate>Fri, 04 Nov 2016 16:17:58 GMT</pubDate>
            <atom:updated>2016-11-23T01:48:20.885Z</atom:updated>
            <content:encoded><![CDATA[<p>Pillow has many dependencies, as you can see <a href="http://pillow.readthedocs.io/en/3.1.x/installation.html">here</a>. I had some trouble trying to install it on Fedora 24. In my case, I was using pip3. What fixed this issue for me was running this command:</p><pre><strong>sudo dnf install redhat-rpm-config</strong></pre><p>The explanation you can find <a href="https://bugs.launchpad.net/openstack-gate/+bug/1424582#yui_3_10_3_1_1449520111630_540">here</a>.</p><p><strong><em>UPDATE:</em></strong><em> make sure you have rpm-build installed too.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48f9b9f71726" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>