Skip to content

Commit

Permalink
Count properties as fields
Browse files Browse the repository at this point in the history
  • Loading branch information
noahd1 committed Jan 8, 2025
1 parent 0cc3342 commit c7fb1e7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 14 deletions.
11 changes: 6 additions & 5 deletions qlty-analysis/src/lang/csharp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ const FUNCTION_DECLARATION_QUERY: &str = r#"
"#;

const FIELD_QUERY: &str = r#"
(field_declaration
(variable_declaration
(variable_declarator name: (identifier) @name)
)
) @field
[(field_declaration
(variable_declaration
(variable_declarator name: (identifier) @name)
)
) @field
(property_declaration name: (identifier) @name) @field]
"#;

pub struct CSharp {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ namespace Fields
public class GetterSetterDeclaration
{
public string Field { get; set; }
public string _field2

public static void Main(string[] args)
{
GetterSetterDeclaration obj = new GetterSetterDeclaration();
obj.Field = "Hello";
obj._field2 = "World";
System.Console.WriteLine(obj.Field);
}
}
Expand Down
38 changes: 29 additions & 9 deletions qlty-cli/tests/lang/csharp/basic.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"metadata": {
"buildId": "[..]",
"result": "ANALYSIS_RESULT_SUCCESS",
"filesAnalyzed": 42,
"filesAnalyzed": 43,
"startTime": "[..]",
"finishTime": "[..]",
"commitMessage": "initial/n",
Expand Down Expand Up @@ -872,6 +872,26 @@
"cyclomatic": 2,
"lcom4": 1
},
{
"buildId": "[..]",
"analyzedAt": "[..]",
"name": "GetterSetterDeclaration.cs",
"fullyQualifiedName": "fields/GetterSetterDeclaration.cs",
"path": "fields/GetterSetterDeclaration.cs",
"kind": "COMPONENT_TYPE_FILE",
"language": "LANGUAGE_C_SHARP",
"files": 1,
"classes": 1,
"functions": 1,
"fields": 2,
"lines": 16,
"codeLines": 14,
"commentLines": 0,
"blankLines": 2,
"complexity": 0,
"cyclomatic": 1,
"lcom4": 0
},
{
"buildId": "[..]",
"analyzedAt": "[..]",
Expand Down Expand Up @@ -1237,16 +1257,16 @@
"fullyQualifiedName": "fields",
"path": "fields",
"kind": "COMPONENT_TYPE_DIRECTORY",
"files": 9,
"classes": 10,
"functions": 12,
"fields": 13,
"lines": 138,
"codeLines": 112,
"files": 10,
"classes": 11,
"functions": 13,
"fields": 15,
"lines": 154,
"codeLines": 126,
"commentLines": 4,
"blankLines": 22,
"blankLines": 24,
"complexity": 0,
"cyclomatic": 10,
"cyclomatic": 11,
"lcom4": 1
},
{
Expand Down

0 comments on commit c7fb1e7

Please sign in to comment.