スキップしてメイン コンテンツに移動

投稿

ラベル(Source Code Analysis)が付いた投稿を表示しています

Visual Studio 2019で静的コード解析 (Static Code Analysis)

最近はVisual Studioも高機能になってきて簡単なコード解析機能はデフォルトで利用できるようになってきました。今回の記事で利用したVisual StudioはVersion 16.9.4です。 サーバー上に継続的にデータを蓄積しているわけではないので、指標の変化は追えませんが、プロジェクト内で改善の必要なファイルはある程度目星をつけられるのではないかと思います。 使い方は簡単で、最上部のメニューの「Analyze > Calculate Code Metrics > For Solution (またはFor {Project名})」を選択すると、コード解析が実行され、Code Metrics Rsultsウィンドウにproject > namespace > class > method の階層で解析結果が表示されます。 解析されるMetricsは下記になります。 Maintenability Index (メンテナンス指標) Cyclomatic Complexity (循環的複雑度) Depth of ingheritance (継承の深さ) Class Coupling (クラスの結合度) Lines of Souce code (コードの行数) Lines of Executable coce (実際に実行されるコードの行数。括弧、コメント、空行を除いた行数)

Java: Compute Source Code Similarity Based on Jaccard Similarity Coefficient

Compute Source Code Similarity I have tried to analyze source code by various methods recently. In this post, I will show you my artifact - Compute source code similarity based on Jaccard Similarity Coefficient. Jaccard Similarity Coefficient is an common and quick techniqueto compute similarity between 2 documents. You can see more details in Jaccard index or MinHash . My similarity computation strategy is below: Calculate hash value for each line for each files. Create set which contains hashes calculated in the above process for the each files. Compute Jaccard Similarity Coefficient for all combinations of the files. Source Code Now I can show you code snippets for compute source code similarity based on Jaccard Similarity Coefficient. Jaccard Simlarity package com.dukesoftware.utils.text; import java.util.HashSet; import java.util.Set; /** * Jaccard similarity coefficient http://en.wikipedia.org/wiki/MinHash */ public class JaccardSimlarity<T> { priv