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

Fixed issue of running kuniri on empty directories #200

Closed
wants to merge 83 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
6cbba50
Do not depend on coveralls to run tests
lucaskanashiro Mar 29, 2017
b53524f
Fixed rubocop errors on lib/kuniri/core/setting.rb
bsesso Mar 31, 2017
a28dac6
Fixed rubocop errors on lib/kuniri/core/kuniri.rb
bsesso Mar 31, 2017
43cb28d
Fixed rubocop errors on lib/kuniri/core/configuration/language_availa…
bsesso Mar 31, 2017
43ea5eb
Fixed rubocop errors on lib/kuniri/core/configure/log_available.rb
bsesso Mar 31, 2017
4880fdc
Merge pull request #191 from kuniri-xp/rubocop_core
Apr 1, 2017
1bb7291
Fixed rubocop errors on lib/kuniri/parser/output_format.rb
bsesso Mar 31, 2017
77b56a5
Fixed rubocop errors on lib/kuniri/parser/output_factory.rb
bsesso Mar 31, 2017
ff2534b
Fixed rubocop errors on lib/kuniri/parser/parser.rb
bsesso Mar 31, 2017
c70358d
Fixed rubocop errors on lib/kuniri/parser/xml_output_format.rb
bsesso Mar 31, 2017
814b68e
Fixed rubocop errors on lib/kuniri/state_machine/OO_structured_fsm/ag…
bsesso Mar 31, 2017
bfc082f
Fixed rubocop errors on lib/kuniri/state_machine/OO_structured_fsm/at…
bsesso Mar 31, 2017
8ca3d9b
Fixed rubocop errors on lib/kuniri/state_machine/OO_structured_fsm/bl…
bsesso Mar 31, 2017
96a412f
Fixed rubocop errors on lib/kuniri/state_machine/OO_structured_fsm/cl…
bsesso Mar 31, 2017
eb8fa9d
Fixed rubocop errors on lib/kuniri/state_machine/OO_structured_fsm/co…
bsesso Mar 31, 2017
7e7062b
Fixed rubocop errors on lib/kuniri/state_machine/OO_structured_fsm/co…
bsesso Mar 31, 2017
fa670f6
Fixed rubocop errors on lib/kuniri/state_machine/OO_structured_fsm/co…
bsesso Mar 31, 2017
9cd1ba6
Fixed rubocop errors on lib/kuniri/state_machine/OO_structured_fsm/fu…
bsesso Mar 31, 2017
9622437
Fixed rubocop errors on lib/kuniri/state_machine/OO_structured_fsm/fu…
bsesso Apr 5, 2017
bc9cd27
Fixed rubocop errors on lib/kuniri/state_machine/OO_structured_fsm/id…
bsesso Apr 5, 2017
4512c03
Fixed rubocop errors on lib/kuniri/state_machine/OO_structured_fsm/in…
bsesso Apr 5, 2017
a9580db
Fixed rubocop errors on lib/kuniri/state_machine/OO_structured_fsm/me…
bsesso Apr 5, 2017
831655f
Fixed rubocop errors on lib/kuniri/state_machine/OO_structured_fsm/mo…
bsesso Apr 5, 2017
6b43458
Fixed rubocop errors on lib/kuniri/state_machine/OO_structured_fsm/oo…
bsesso Apr 5, 2017
177cc4e
Fixed rubocop errors on lib/kuniri/state_machine/OO_structured_fsm/re…
bsesso Apr 5, 2017
5bb73b7
Fixed rubocop errors on lib/kuniri/state_machine/OO_structured_fsm/to…
bsesso Apr 5, 2017
d5da27b
Fixed rubocop errors on lib/kuniri/state_machine/OO_structured_fsm/va…
bsesso Apr 5, 2017
87baead
Fixed rubocop errors on lib/kuniri/language/language.rb
bsesso Apr 5, 2017
7613e53
Fixed rubocop errors on lib/kuniri/language/language_factory.rb
bsesso Apr 5, 2017
02d6e08
Fixed rubocop errors on lib/kuniri/language/metadata.rb
bsesso Apr 5, 2017
099ca20
Fixed rubocop errors on lib/kuniri/language/abstract_container/struct…
bsesso Apr 5, 2017
d3967c6
Fixed rubocop errors on lib/kuniri/language/abstract_container/struct…
bsesso Apr 5, 2017
ac79721
Fixed rubocop errors on lib/kuniri/language/abstract_container/struct…
bsesso Apr 5, 2017
661f9c0
Fixed rubocop errors on lib/kuniri/language/abstract_container/struct…
bsesso Apr 5, 2017
bdd791e
Fixed rubocop errors on lib/kuniri/language/abstract_container/struct…
bsesso Apr 5, 2017
07a6419
Fixed rubocop errors on lib/kuniri/language/abstract_container/struct…
bsesso Apr 5, 2017
5f1ab9b
Fixed rubocop errors on lib/kuniri/language/abstract_container/struct…
bsesso Apr 5, 2017
ad2a665
Fixed rubocop errors on lib/kuniri/language/abstract_container/struct…
bsesso Apr 5, 2017
faed6d9
Fixed rubocop errors on lib/kuniri/language/abstract_container/struct…
bsesso Apr 5, 2017
9a133ce
Fixed rubocop errors on lib/kuniri/language/abstract_container/struct…
bsesso Apr 5, 2017
9ece287
Fixed rubocop errors on lib/kuniri/language/abstract_container/struct…
bsesso Apr 5, 2017
a663a2f
Fixed rubocop errors on lib/kuniri/language/abstract_container/struct…
bsesso Apr 5, 2017
82ee905
Merge branch 'kuniri-xp-rubocop_parser' into dev
rodrigosiqueira Apr 5, 2017
2933e07
Merge branch 'rubocop_state_machine' of https://github.com/kuniri-xp/…
rodrigosiqueira Apr 5, 2017
9f1c715
Merge branch 'kuniri-xp-rubocop_state_machine' into dev
rodrigosiqueira Apr 5, 2017
a99b9f9
Fixed rubocop errors on lib/kuniri/language/abstract_container/struct…
bsesso Apr 6, 2017
50bd28b
Fixed rubocop errors on lib/kuniri/language/abstract_container/struct…
bsesso Apr 6, 2017
1b643e7
Fixed rubocop errors on lib/kuniri/language/abstract_container/struct…
bsesso Apr 6, 2017
76eee31
Fixed rubocop errors on lib/kuniri/language/container_data/stucturued…
bsesso Apr 6, 2017
988c825
Fixed rubocop errors on lib/kuniri/language/container_data/stucturued…
bsesso Apr 6, 2017
e4b3a01
Fixed rubocop errors on lib/kuniri/language/container_data/stucturued…
bsesso Apr 6, 2017
6c9bb86
Fixed rubocop errors on lib/kuniri/language/container_data/stucturued…
bsesso Apr 6, 2017
86846d4
Fixed rubocop errors on lib/kuniri/language/container_data/stucturued…
bsesso Apr 6, 2017
c3d421e
Fixed rubocop errors on lib/kuniri/language/container_data/stucturued…
bsesso Apr 6, 2017
87d9e9b
Fixed rubocop errors on lib/kuniri/language/container_data/stucturued…
bsesso Apr 6, 2017
25ac5df
Fixed rubocop errors on lib/kuniri/language/container_data/stucturued…
bsesso Apr 6, 2017
7888415
Fixed rubocop errors on lib/kuniri/language/container_data/stucturued…
bsesso Apr 6, 2017
070278c
Fixed rubocop errors on lib/kuniri/language/container_data/stucturued…
bsesso Apr 6, 2017
eb9fcd6
Fixed rubocop errors on lib/kuniri/language/container_data/stucturued…
bsesso Apr 6, 2017
b356db2
Fixed rubocop errors on lib/kuniri/language/container_data/stucturued…
bsesso Apr 6, 2017
f45d9a4
Fixed rubocop errors on lib/kuniri/language/container_data/stucturued…
bsesso Apr 6, 2017
11167a2
Fixed rubocop errors on lib/kuniri/language/container_data/stucturued…
bsesso Apr 6, 2017
d799747
Fixed rubocop errors on lib/kuniri/language/container_data/stucturued…
bsesso Apr 6, 2017
53384ff
Fixed rubocop errors on lib/kuniri/language/container_data/stucturued…
bsesso Apr 6, 2017
6a186bc
Fixed rubocop errors on lib/kuniri/language/ruby/aggregation_ruby.rb
bsesso Apr 6, 2017
813abb5
Fixed rubocop errors on lib/kuniri/language/ruby/attribute_ruby.rb
bsesso Apr 6, 2017
6eac86d
Fixed rubocop errors on lib/kuniri/language/ruby/block_ruby.rb
bsesso Apr 6, 2017
582b138
Fixed rubocop errors on lib/kuniri/language/ruby/class_ruby.rb
bsesso Apr 6, 2017
7373f14
Fixed rubocop errors on lib/kuniri/language/ruby/comment_ruby.rb
bsesso Apr 6, 2017
6edad0c
Fixed rubocop errors on lib/kuniri/language/ruby/constructor_ruby.rb
bsesso Apr 6, 2017
d7a9bea
Fixed rubocop errors on lib/kuniri/language/ruby/end_block_ruby.rb
bsesso Apr 6, 2017
5d7b324
Fixed rubocop errors on lib/kuniri/language/ruby/extern_requirement_r…
bsesso Apr 6, 2017
a0c7492
Fixed rubocop errors on lib/kuniri/language/ruby/function_behavior_ru…
bsesso Apr 6, 2017
bbf0216
Fixed rubocop errors on lib/kuniri/language/ruby/global_function_ruby.rb
bsesso Apr 6, 2017
c9b7aab
Fixed rubocop errors on lib/kuniri/language/ruby/method_ruby.rb
bsesso Apr 6, 2017
1c196db
Fixed rubocop errors on lib/kuniri/language/ruby/module_namespace_rub…
bsesso Apr 6, 2017
e2e3c38
Fixed rubocop errors on lib/kuniri/language/ruby/repetition_ruby.rb
bsesso Apr 6, 2017
777677a
Fixed rubocop errors on lib/kuniri/language/ruby/ruby_syntax.rb
bsesso Apr 6, 2017
afef54f
Fixed rubocop errors on lib/kuniri/language/ruby/token_ruby.rb
bsesso Apr 6, 2017
e888a3c
Fixed rubocop errors on lib/kuniri/language/ruby/variable_behaviour_r…
bsesso Apr 6, 2017
76d96c4
Fixed rubocop errors on lib/kuniri/language/ruby/variable_global_ruby.rb
bsesso Apr 6, 2017
236aae0
Merge branch 'kuniri-xp-rubocop_language' into dev
rodrigosiqueira Apr 7, 2017
5146a67
Fixed error of running kuniri on empty folder
bsesso Apr 7, 2017
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
2 changes: 1 addition & 1 deletion data/end_block_lang.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class EndBlock{LANG} < Languages::EndBlock

# Verify {LANG} end of block.
# @see EndBlock
def has_end_of_block?(pLine)
def end_of_block?(pLine)
# YOUR CODE HERE
end

Expand Down
5 changes: 2 additions & 3 deletions lib/kuniri/core/configuration/language_available.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
# Version 3. See the file COPYING for more details

module Configuration
#Handling the languages available in the system.
# Handling the languages available in the system.
class LanguageAvailable
public
LANGUAGES = ["ruby", "python", "cplusplus", "c"] #Put here new language.
LANGUAGES = %w(ruby python cplusplus c).freeze # Put here new language.
end
end
5 changes: 2 additions & 3 deletions lib/kuniri/core/configuration/log_available.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

module Configuration
# Configuration for the monitor available.
class Log_Available
public
LOG = ["html", "txt"] #List with log types.
class LogAvailable
LOG = %w(html txt).freeze # List with log types.
end
end
45 changes: 18 additions & 27 deletions lib/kuniri/core/kuniri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ class Kuniri
def initialize
@configurationInfo = {}
@filesPathProject = []
@parserFiles = []
@parser = nil
@parserFiles = [] # !@attribute Final output from parser.
@filesProject = [] # !@attribute Array with object reference of all files
@parser = nil # !@attribute Execute the parser based on settings.
end

def read_configuration_file(pPath = '.kuniri.yml')
Expand All @@ -38,10 +39,10 @@ def read_configuration_file(pPath = '.kuniri.yml')
def set_configuration(pSource, pLanguage, pOutput, pLevel)
@settings = Setting.create
@settings.initializate_settings
@configurationInfo = {language: pLanguage,
source: pSource,
output: pOutput,
pLevel: pLevel}
@configurationInfo = { language: pLanguage,
source: pSource,
output: pOutput,
pLevel: pLevel }

@settings.set_configuration(@configurationInfo)
end
Expand All @@ -58,7 +59,11 @@ def run_analysis
@parser = Parser::Parser.new(@filesPathProject,
@configurationInfo[:language])
Util::LoggerKuniri.info('Start parse...')
@parser.start_parser
begin
@parser.start_parser
rescue Error::ConfigurationFileError => e
puts e.message
end
end

def get_parser
Expand All @@ -67,29 +72,15 @@ def get_parser

private

@filesProject # !@attribute Array with object reference of all files
@parser # !@attribute Execute the parser based on settings.
@parserFiles # !@attribute Final output from parser.

# !@param pPath Relative path of the project.
# !@param pLanguage Language extension for make the parser.
def get_project_file(pPath = './', pLanguage = '**.rb')
# Verify if path is a valid directory or file
return nil unless File.file?(pPath) or File.directory?(pPath)

# Handle single file
if (File.file?(pPath))
@filesProject = [pPath]
# Handle multiple files
else
@filesProject = Dir[File.join(pPath, '**', pLanguage)]
end
return nil unless File.file?(pPath) || File.directory?(pPath)

return @filesProject
# Handle single file and multiple files
@filesProject =
File.file?(pPath) ? [pPath] : Dir[File.join(pPath, '**', pLanguage)]
end

# Class
end

# Kuniri
end
end # Class
end # Kuniri
95 changes: 45 additions & 50 deletions lib/kuniri/core/setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def initialize
end

def self.create
@@settings = new unless @@settings
return @@settings
@settings = new unless @settings
return @settings
end

# TODO: Remove parameter and initialize_object. Useless.
Expand All @@ -37,7 +37,6 @@ def initializate_settings
# @return [Hash] Return a Hash with the configurations read in ".kuniri",
# otherwise, raise an exception.
def read_configuration_file(pPath = '.kuniri.yml')

if !(File.exist?(pPath))
set_default_configuration
else
Expand All @@ -54,62 +53,58 @@ def set_configuration(configurationInfo)

private

@@settings = nil

def set_default_configuration
@configurationInfo = {:language => "ruby",
:source => "./",
:output => "./"}
end
@settings = nil

def verify_syntax
unless @configurationInfo.is_a? Hash
Util::LoggerKuniri.error('Configuration file has a syntax problem')
raise Error::ConfigurationFileError
end
def set_default_configuration
@configurationInfo = { language: 'ruby',
source: './',
output: './' }
end

check_source
check_output
check_language
def verify_syntax
unless @configurationInfo.is_a? Hash
Util::LoggerKuniri.error('Configuration file has a syntax problem')
raise Error::ConfigurationFileError
end

def check_source
unless @configurationInfo.has_key?:source
Util::LoggerKuniri.error('Problem with source parameter')
raise Error::ConfigurationFileError
else
source = @configurationInfo[:source]
result = (File.directory?source) || (File.exists?source)
unless result
Util::LoggerKuniri.error('Wrong path on source')
raise Error::ConfigurationFileError
end
end
end
check_source
check_output
check_language
end

def check_output
unless @configurationInfo.has_key?:output
Util::LoggerKuniri.error('Problem with output field')
def check_source
if !@configurationInfo.key?:source
Util::LoggerKuniri.error('Problem with source parameter')
raise Error::ConfigurationFileError
else
source = @configurationInfo[:source]
result = (File.directory?source) || (File.exist?source)
unless result
Util::LoggerKuniri.error('Wrong path on source')
raise Error::ConfigurationFileError
end
end
end

def check_output
return if @configurationInfo.key?:output
Util::LoggerKuniri.error('Problem with output field')
raise Error::ConfigurationFileError
end

def check_language
unless @configurationInfo.has_key?:language
Util::LoggerKuniri.error('Problem with language field')
def check_language
if !@configurationInfo.key?:language
Util::LoggerKuniri.error('Problem with language field')
raise Error::ConfigurationFileError
else
result = Configuration::LanguageAvailable::LANGUAGES.include?(
@configurationInfo[:language]
)
unless result
Util::LoggerKuniri.error('Problem with specified language')
raise Error::ConfigurationFileError
else
result = Configuration::LanguageAvailable::LANGUAGES.include?(
@configurationInfo[:language])
unless result
Util::LoggerKuniri.error('Problem with specified language')
raise Error::ConfigurationFileError
end
end
end

# Class
end

# Module
end
end
end # Class
end # Module
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,22 @@ module Languages

# @abstract Aggregation is a container for handling aggregation among classes
class Aggregation

public

# Verify if line has an aggregation.
# @param pLine Line with the potential class.
# @return Return an object AggregationData if it find a class in the
# line, otherwise return nil.
def get_aggregation(pLine)
raise NotImplementedError
end
# Verify if line has an aggregation.
# @param pLine Line with the potential class.
# @return Return an object AggregationData if it find a class in the
# line, otherwise return nil.
def get_aggregation(_pLine)
raise NotImplementedError
end

protected

# Detect if an aggregation exists.
# @param pLine Line to inspect.
# @return Returns an row string, otherwise returns nil.
def detect_aggregation(pLine)
raise NotImplementedError
end

# class
end
# Detect if an aggregation exists.
# @param pLine Line to inspect.
# @return Returns an row string, otherwise returns nil.
def detect_aggregation(_pLine)
raise NotImplementedError
end

# module
end
end # class
end # module
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,18 @@ module Languages

# @abstract Abstract class for handling attribute.
class Attribute

public

include VariableBehaviourHelpers

# Verify if a line has an attribute. If it has attribute, firstly, the
# function capture all lines and removes specific language declaration
# (for instance, in ruby it is: '@' or ':' and whitespace), finally
# it splits the string by an special character and return an object of
# AttributeData.
# @param pLine An line to be analysed for find attribute.
# @return Return on filled object of AttributeData if it find an
# attribute, otherwise it returns nil.
def get_attribute(pLine)
raise NotImplementedError
end

protected

@variableBehaviour

# Class
end

# Language
end
include VariableBehaviourHelpers

# Verify if a line has an attribute. If it has attribute, firstly, the
# function capture all lines and removes specific language declaration
# (for instance, in ruby it is: '@' or ':' and whitespace), finally
# it splits the string by an special character and return an object of
# AttributeData.
# @param pLine An line to be analysed for find attribute.
# @return Return on filled object of AttributeData if it find an
# attribute, otherwise it returns nil.
def get_attribute(_pLine)
raise NotImplementedError
end
end # Class
end # Language
71 changes: 32 additions & 39 deletions lib/kuniri/language/abstract_container/structured_and_oo/block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,38 @@ module Languages

# @abstract Class responsible for handling block.
class Block

public
# Verify if a line has an block. If it has block, firstly, the
# function capture all lines.
# @param pLine An line to be analysed for find block.
# @return Return on filled object of BlockData if it find an
# block, otherwise it returns nil.
def get_block(pLine)
raise NotImplementedError
end
# Verify if a line has an block. If it has block, firstly, the
# function capture all lines.
# @param pLine An line to be analysed for find block.
# @return Return on filled object of BlockData if it find an
# block, otherwise it returns nil.
def get_block(_pLine)
raise NotImplementedError
end

protected

# Method with a regex to check if line has a block.
# @param pLine String with potential block inside.
# @return Partial string with detection, otherwise return nil.
def detect_block(pLine)
raise NotImplementedError
end


# Set the name of the block based on the name captured.
# Note: If this method is executed, we suppose we already have a block
# as a string.
# @param pString Partial string to be handled.
# @return String with block name in uppercase.
def capture_block_name(pString)
raise NotImplementedError
end

# Extract expression from the captured string.
# @param pString Full string.
# @return String with name expression.
def capture_expression(pString)
raise NotImplementedError
end

# End class
end

# module
end
# Method with a regex to check if line has a block.
# @param pLine String with potential block inside.
# @return Partial string with detection, otherwise return nil.
def detect_block(_pLine)
raise NotImplementedError
end

# Set the name of the block based on the name captured.
# Note: If this method is executed, we suppose we already have a block
# as a string.
# @param pString Partial string to be handled.
# @return String with block name in uppercase.
def capture_block_name(_pString)
raise NotImplementedError
end

# Extract expression from the captured string.
# @param pString Full string.
# @return String with name expression.
def capture_expression(_pString)
raise NotImplementedError
end
end # End class
end # module
Loading