Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Halstead implementation for Java #811

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cleanup comments and println
  • Loading branch information
dburriss committed May 26, 2022
commit 1f14f484e43da65ee54aa6218e7ec7284028fa8c
18 changes: 1 addition & 17 deletions src/getter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,21 +527,9 @@ impl Getter for JavaCode {

fn get_op_type(node: &Node) -> HalsteadType {
use Java::*;

// Some guides that informed grammar choice for Halstead
// keywords, operators, literals: https://docs.oracle.com/javase/specs/jls/se18/html/jls-3.html#jls-3.12
// https://www.geeksforgeeks.org/software-engineering-halsteads-software-metrics/?msclkid=5e181114abef11ecbb03527e95a34828
//
// comments not considered
// Operator: function calls?
// Operator: control flow
// Operator: keywords
// Operator: brackets and comma and terminators
// Operator: operators
// Operator: InstanceOf
// Operator: .
// Operand: struct name
// Operand: vars and const

let typ = node.object().kind_id();

match typ.into() {
Expand All @@ -561,17 +549,13 @@ impl Getter for JavaCode {
// type identifier
| TypeIdentifier | IntegralType | FloatingPointType | BooleanType
=> {
println!("operator: {}", node.object().kind());
HalsteadType::Operator
},

// Operands: variables, constants, literals
Identifier | NullLiteral | ClassLiteral | StringLiteral | CharacterLiteral | HexIntegerLiteral | OctalIntegerLiteral | BinaryIntegerLiteral | DecimalIntegerLiteral | HexFloatingPointLiteral | DecimalFloatingPointLiteral => {
dburriss marked this conversation as resolved.
Show resolved Hide resolved
println!("operand: {} ", node.object().kind());
HalsteadType::Operand
},
_ => {
println!("unknown: {} ", node.object().kind());
HalsteadType::Unknown
},
}
Expand Down