<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ayodeji Moronkeji</title>
    <description>The latest articles on DEV Community by Ayodeji Moronkeji (@morayodeji).</description>
    <link>https://dev.to/morayodeji</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F35958%2F5073fcf9-1808-424b-8241-e1ab3b2d5ccc.jpg</url>
      <title>DEV Community: Ayodeji Moronkeji</title>
      <link>https://dev.to/morayodeji</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/morayodeji"/>
    <language>en</language>
    <item>
      <title>How I obtained the true lines of code in my project.</title>
      <dc:creator>Ayodeji Moronkeji</dc:creator>
      <pubDate>Sun, 05 Jan 2025 04:25:48 +0000</pubDate>
      <link>https://dev.to/morayodeji/how-i-obtained-the-true-lines-of-code-in-my-project-4mp2</link>
      <guid>https://dev.to/morayodeji/how-i-obtained-the-true-lines-of-code-in-my-project-4mp2</guid>
      <description>&lt;p&gt;In software development, accurately measuring the size of a codebase is essential for project management, resource allocation, and progress tracking. However, traditional tools often include auto-generated and data files, such as package-lock.json, yarn.lock, and data.json, etc. in their line counts. This leads to inflated metrics because technically, you didn't add the lines of code by yourself. To address this challenge, I developed git-repo-lines-of-code, an open-source project designed to provide precise line counts by excluding specified files.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Motivation Behind git-repo-lines-of-code
&lt;/h2&gt;

&lt;p&gt;While tools like &lt;a href="https://github.com/AlDanial/cloc?tab=readme-ov-file" rel="noopener noreferrer"&gt;cloc&lt;/a&gt; are popular for counting lines of code, they don't offer straightforward mechanisms to exclude specific files or patterns, especially when dealing with auto-generated files that can skew the analysis. This limitation prompted the creation of a tool that allows developers and managers to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Exclude Unwanted Files: Omit files that do not contribute to the actual codebase, ensuring more accurate metrics.&lt;/li&gt;
&lt;li&gt;Automate the Counting Process: Eliminate the need for manual adjustments, reducing errors and saving time.&lt;/li&gt;
&lt;li&gt;Enhance Reusability: Provide a solution that is easily integrated into various projects and workflows.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to Use git-repo-lines-of-code
&lt;/h2&gt;

&lt;p&gt;To get started with git-repo-lines-of-code, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Installation: Install the package globally using npm:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; git-repo-lines-of-code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Basic Usage:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;getRepoLinesOfCode&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;git-repo-lines-of-code&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;owner&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;octocat&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;repo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello-World&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;excludeFilePaths&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path-to-file.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path-to-auto-generated-code.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nf"&gt;getRepoLinesOfCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;owner&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;repo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;excludeFilePaths&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;linesOfCode&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Total lines of code: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;linesOfCode&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Error: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running this function will execute the line count with the specified exclusions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;git-repo-lines-of-code offers a streamlined approach to accurately measuring your codebase by excluding non-essential files. Its flexibility and ease of use make it a valuable tool for developers and managers seeking precise code metrics.&lt;/p&gt;

&lt;p&gt;The package is open-source, and contributions are welcome. You can access the &lt;a href="https://www.npmjs.com/package/git-repo-lines-of-code/v/1.0.2?activeTab=readme" rel="noopener noreferrer"&gt;npm package here&lt;/a&gt; and the &lt;a href="https://github.com/d-beloved/git-repo-lines-of-code" rel="noopener noreferrer"&gt;GitHub repository here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Please, feel free to explore, contribute, and integrate it into your projects to maintain accurate code metrics.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>metrics</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
